Explicitly test for inequality in JIDs.

Fixes issue #113
This commit is contained in:
Lance Stout 2011-11-14 09:15:43 -08:00
parent 9f9e8db814
commit 43c4d23896
2 changed files with 19 additions and 0 deletions

View file

@ -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

View file

@ -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)