From 071f3916f8a74906789c5c770fc1ae44c8306038 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 8 Sep 2003 20:29:02 +0000 Subject: [PATCH] Most IrcMsg.__hash__ were returning 0, because I was using & instead of ^ --- src/ircmsgs.py | 4 ++-- test/test_ircmsgs.py | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ircmsgs.py b/src/ircmsgs.py index f1f22299a..e273d2461 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -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 diff --git a/test/test_ircmsgs.py b/test/test_ircmsgs.py index 3d9721689..92fece3a9 100644 --- a/test/test_ircmsgs.py +++ b/test/test_ircmsgs.py @@ -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'