Commit cc26310e authored by Victor Stinner's avatar Victor Stinner

Issue #20162: test_hash_distribution() uses subTest() to mention the prefix in

the error message.
parent 1500d49c
...@@ -330,15 +330,16 @@ class HashDistributionTestCase(unittest.TestCase): ...@@ -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()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment