summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-12-31 02:01:33 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-12-31 02:01:33 (GMT)
commit6e70accaffc61a5af7d78be1b365d1cab804751b (patch)
tree388e802f8c88d84a04f46142e481301033131f3c /Lib
parented54d91ef51bd2d0c7e63d08e6f7e003434aa524 (diff)
downloadcpython-6e70accaffc61a5af7d78be1b365d1cab804751b.zip
cpython-6e70accaffc61a5af7d78be1b365d1cab804751b.tar.gz
cpython-6e70accaffc61a5af7d78be1b365d1cab804751b.tar.bz2
Strengthen the test for hash effectiveness
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_set.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 5d37169..2104ee9 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -389,12 +389,12 @@ class TestFrozenSet(TestJointOps):
def test_hash_effectiveness(self):
n = 13
- rng = range(n)
hashvalues = set()
+ addhashvalue = hashvalues.add
+ elemmasks = [(i+1, 1<<i) for i in range(n)]
for i in xrange(2**n):
- combination = [j for j in rng if (1<<j)&i]
- hashvalues.add(hash(self.thetype(combination)))
- self.assert_(len(hashvalues) >= 2**(n-2))
+ addhashvalue(hash(frozenset([e for e, m in elemmasks if m&i])))
+ self.assertEqual(len(hashvalues), 2**n)
class FrozenSetSubclass(frozenset):
pass