]> granicus.if.org Git - python/commitdiff
Issue 3161: Missing import and test.
authorRaymond Hettinger <python@rcn.com>
Mon, 23 Jun 2008 03:29:28 +0000 (03:29 +0000)
committerRaymond Hettinger <python@rcn.com>
Mon, 23 Jun 2008 03:29:28 +0000 (03:29 +0000)
Lib/_abcoll.py
Lib/test/test_collections.py

index 5acbb701b69bfc6a03557c94dfb83b5d3ab2aec4..85d733f39c5f416c22aefd98eed5982876f93340 100644 (file)
@@ -9,6 +9,7 @@ bootstrapping issues.  Unit tests are in test_collections.
 """
 
 from abc import ABCMeta, abstractmethod
+import sys
 
 __all__ = ["Hashable", "Iterable", "Iterator",
            "Sized", "Container", "Callable",
index 4f823e393ce0efc9e9e676f3a209aeed1a911b14..99eb8cf9addb623fe33140d665f6167f0d8cd3d0 100644 (file)
@@ -294,6 +294,21 @@ class TestCollectionABCs(unittest.TestCase):
             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))