From 43c4d23896437dbab9f6cfbe80e885394b84b638 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 14 Nov 2011 09:15:43 -0800 Subject: Explicitly test for inequality in JIDs. Fixes issue #113 --- sleekxmpp/xmlstream/jid.py | 6 ++++++ tests/test_jid.py | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/sleekxmpp/xmlstream/jid.py b/sleekxmpp/xmlstream/jid.py index 36b33056..3d617f5a 100644 --- a/sleekxmpp/xmlstream/jid.py +++ b/sleekxmpp/xmlstream/jid.py @@ -135,3 +135,9 @@ class JID(object): """ other = JID(other) return self.full == other.full + + def __ne__(self, other): + """ + Two JIDs are considered unequal if they are not equal. + """ + return not self == other diff --git a/tests/test_jid.py b/tests/test_jid.py index 99402999..ef1145d3 100644 --- a/tests/test_jid.py +++ b/tests/test_jid.py @@ -124,5 +124,18 @@ class TestJIDClass(SleekTest): 'component.someserver', 'component.someserver') + def testJIDEquality(self): + """Test that JIDs with the same content are equal.""" + jid1 = JID('user@domain/resource') + jid2 = JID('user@domain/resource') + self.assertTrue(jid1 == jid2, "Same JIDs are not considered equal") + self.assertFalse(jid1 != jid2, "Same JIDs are considered not equal") + + def testJIDInequality(self): + jid1 = JID('user@domain/resource') + jid2 = JID('otheruser@domain/resource') + self.assertFalse(jid1 == jid2, "Same JIDs are not considered equal") + self.assertTrue(jid1 != jid2, "Same JIDs are considered not equal") + suite = unittest.TestLoader().loadTestsFromTestCase(TestJIDClass) -- cgit v1.2.3