]> granicus.if.org Git - python/commitdiff
Issue #20162: test_hash_distribution() uses subTest() to mention the prefix in
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 7 Jan 2014 13:40:51 +0000 (14:40 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 7 Jan 2014 13:40:51 +0000 (14:40 +0100)
the error message.

Lib/test/test_hash.py

index f6657bd3cb70db0a28b6bcb55aee963edeb1e53f..3d2859fdd0db58f3d1b87f91ed9e6ba6377392f1 100644 (file)
@@ -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()