[Python-checkins] r54250 - python/trunk/Lib/unittest.py

collin.winter python-checkins at python.org
Sat Mar 10 00:30:40 CET 2007


Author: collin.winter
Date: Sat Mar 10 00:30:39 2007
New Revision: 54250

Modified:
   python/trunk/Lib/unittest.py
Log:
Hashing simplification pointed out by Thomas Wouters.

Modified: python/trunk/Lib/unittest.py
==============================================================================
--- python/trunk/Lib/unittest.py	(original)
+++ python/trunk/Lib/unittest.py	Sat Mar 10 00:30:39 2007
@@ -245,7 +245,7 @@
         return not self == other
 
     def __hash__(self):
-        return hash(str(hash(type(self))) + str(hash(self._testMethodName)))
+        return hash((type(self), self._testMethodName))
 
     def __str__(self):
         return "%s (%s)" % (self._testMethodName, _strclass(self.__class__))
@@ -502,9 +502,8 @@
         return not self == other
 
     def __hash__(self):
-        return hash(''.join(str(hash(x)) for x in [
-            type(self), self.__setUpFunc, self.__tearDownFunc, self.__testFunc,
-            self.__description]))
+        return hash((type(self), self.__setUpFunc, self.__tearDownFunc,
+                                           self.__testFunc, self.__description))
 
     def __str__(self):
         return "%s (%s)" % (_strclass(self.__class__), self.__testFunc.__name__)


More information about the Python-checkins mailing list