Most IrcMsg.__hash__ were returning 0, because I was using & instead of ^

This commit is contained in:
Jeremy Fincher 2003-09-08 20:29:02 +00:00
parent cec0f77538
commit 071f3916f8
2 changed files with 9 additions and 2 deletions

View File

@ -168,8 +168,8 @@ class IrcMsg(object):
def __hash__(self):
if self._hash is not None:
return self._hash
self._hash = hash(self.command) & \
hash(self.prefix) & \
self._hash = hash(self.command) ^ \
hash(self.prefix) ^ \
hash(self.args)
return self._hash

View File

@ -97,6 +97,13 @@ class IrcMsgTestCase(unittest.TestCase):
self.assertEqual(msg, pickle.loads(pickle.dumps(msg)))
self.assertEqual(msg, copy.copy(msg))
def testHashNotZero(self):
zeroes = 0
for msg in msgs:
if hash(msg) == 0:
zeroes += 1
self.failIf(zeroes > (len(msgs)/10), 'Too many zero hashes.')
class FunctionsTestCase(unittest.TestCase):
def testIsAction(self):
L = [':jemfinch!~jfincher@ts26-2.homenet.ohio-state.edu PRIVMSG'