[Python-checkins] r64475 - in python/trunk/Lib: _abcoll.py test/test_collections.py

raymond.hettinger python-checkins at python.org
Mon Jun 23 05:29:28 CEST 2008


Author: raymond.hettinger
Date: Mon Jun 23 05:29:28 2008
New Revision: 64475

Log:
Issue 3161: Missing import and test.

Modified:
   python/trunk/Lib/_abcoll.py
   python/trunk/Lib/test/test_collections.py

Modified: python/trunk/Lib/_abcoll.py
==============================================================================
--- python/trunk/Lib/_abcoll.py	(original)
+++ python/trunk/Lib/_abcoll.py	Mon Jun 23 05:29:28 2008
@@ -9,6 +9,7 @@
 """
 
 from abc import ABCMeta, abstractmethod
+import sys
 
 __all__ = ["Hashable", "Iterable", "Iterator",
            "Sized", "Container", "Callable",

Modified: python/trunk/Lib/test/test_collections.py
==============================================================================
--- python/trunk/Lib/test/test_collections.py	(original)
+++ python/trunk/Lib/test/test_collections.py	Mon Jun 23 05:29:28 2008
@@ -294,6 +294,21 @@
             self.failUnless(isinstance(sample(), Set))
             self.failUnless(issubclass(sample, Set))
 
+    def test_hash_Set(self):
+        class OneTwoThreeSet(Set):
+            def __init__(self):
+                self.contents = [1, 2, 3]
+            def __contains__(self, x):
+                return x in self.contents
+            def __len__(self):
+                return len(self.contents)
+            def __iter__(self):
+                return iter(self.contents)
+            def __hash__(self):
+                return self._hash()
+        a, b = OneTwoThreeSet(), OneTwoThreeSet()
+        self.failUnless(hash(a) == hash(b))
+
     def test_MutableSet(self):
         self.failUnless(isinstance(set(), MutableSet))
         self.failUnless(issubclass(set, MutableSet))


More information about the Python-checkins mailing list