mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
Issue #20162: test_hash_distribution() uses subTest() to mention the prefix in
the error message.
This commit is contained in:
parent
1500d49c22
commit
cc26310e2e
1 changed files with 10 additions and 9 deletions
|
@ -330,15 +330,16 @@ class HashDistributionTestCase(unittest.TestCase):
|
||||||
base = "abcdefghabcdefg"
|
base = "abcdefghabcdefg"
|
||||||
for i in range(1, len(base)):
|
for i in range(1, len(base)):
|
||||||
prefix = base[:i]
|
prefix = base[:i]
|
||||||
s15 = set()
|
with self.subTest(prefix=prefix):
|
||||||
s255 = set()
|
s15 = set()
|
||||||
for c in range(256):
|
s255 = set()
|
||||||
h = hash(prefix + chr(c))
|
for c in range(256):
|
||||||
s15.add(h & 0xf)
|
h = hash(prefix + chr(c))
|
||||||
s255.add(h & 0xff)
|
s15.add(h & 0xf)
|
||||||
# SipHash24 distribution depends on key, usually > 60%
|
s255.add(h & 0xff)
|
||||||
self.assertGreater(len(s15), 8, prefix)
|
# SipHash24 distribution depends on key, usually > 60%
|
||||||
self.assertGreater(len(s255), 128, prefix)
|
self.assertGreater(len(s15), 8, prefix)
|
||||||
|
self.assertGreater(len(s255), 128, prefix)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue