summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_hash.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-01-07 13:40:51 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-01-07 13:40:51 (GMT)
commitcc26310e2edf89a59a95e6836a1cca0ced4d8adc (patch)
treee88a4ae3d7a91ed22e1b3202473ab7d7ffe67f1b /Lib/test/test_hash.py
parent1500d49c22e1a38d186f2dddfa6ba2c5a6cd7d5e (diff)
downloadcpython-cc26310e2edf89a59a95e6836a1cca0ced4d8adc.zip
cpython-cc26310e2edf89a59a95e6836a1cca0ced4d8adc.tar.gz
cpython-cc26310e2edf89a59a95e6836a1cca0ced4d8adc.tar.bz2
Issue #20162: test_hash_distribution() uses subTest() to mention the prefix in
the error message.
Diffstat (limited to 'Lib/test/test_hash.py')
-rw-r--r--Lib/test/test_hash.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/Lib/test/test_hash.py b/Lib/test/test_hash.py
index f6657bd..3d2859f 100644
--- a/Lib/test/test_hash.py
+++ b/Lib/test/test_hash.py
@@ -330,15 +330,16 @@ class HashDistributionTestCase(unittest.TestCase):
base = "abcdefghabcdefg"
for i in range(1, len(base)):
prefix = base[:i]
- s15 = set()
- s255 = set()
- for c in range(256):
- h = hash(prefix + chr(c))
- s15.add(h & 0xf)
- s255.add(h & 0xff)
- # SipHash24 distribution depends on key, usually > 60%
- self.assertGreater(len(s15), 8, prefix)
- self.assertGreater(len(s255), 128, prefix)
+ with self.subTest(prefix=prefix):
+ s15 = set()
+ s255 = set()
+ for c in range(256):
+ h = hash(prefix + chr(c))
+ s15.add(h & 0xf)
+ s255.add(h & 0xff)
+ # SipHash24 distribution depends on key, usually > 60%
+ self.assertGreater(len(s15), 8, prefix)
+ self.assertGreater(len(s255), 128, prefix)
if __name__ == "__main__":
unittest.main()