summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_set.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2005-08-12 23:47:50 (GMT)
committerRaymond Hettinger <python@rcn.com>2005-08-12 23:47:50 (GMT)
commit787b4c5fea8476a1146918f90a6da7f63d7aa31c (patch)
tree53d7c83df4d9ca4bf38d7975b1f05d2666a249b5 /Lib/test/test_set.py
parent7297ba01b17caea4ed28d4e92e3642053730e4f3 (diff)
downloadcpython-787b4c5fea8476a1146918f90a6da7f63d7aa31c.zip
cpython-787b4c5fea8476a1146918f90a6da7f63d7aa31c.tar.gz
cpython-787b4c5fea8476a1146918f90a6da7f63d7aa31c.tar.bz2
* SF bug #1257731: Fix logic in set.__contains__(), set.remove(),
and set.discard for handling keys that both inherite from set and define their own __hash__() function. * Fixed O(n) performance issue with set.pop() which should have been an O(1) process.
Diffstat (limited to 'Lib/test/test_set.py')
-rw-r--r--Lib/test/test_set.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 26e38ab..b4c7c4f 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -212,6 +212,19 @@ class TestJointOps(unittest.TestCase):
elem.sub = elem
elem.set = set([elem])
+ def test_subclass_with_custom_hash(self):
+ # Bug #1257731
+ class H(self.thetype):
+ def __hash__(self):
+ return id(self)
+ s=H()
+ f=set()
+ f.add(s)
+ self.assert_(s in f)
+ f.remove(s)
+ f.add(s)
+ f.discard(s)
+
class TestSet(TestJointOps):
thetype = set