summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_hash.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_hash.py')
-rw-r--r--Lib/test/test_hash.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/test/test_hash.py b/Lib/test/test_hash.py
index c0dd34d..0776779 100644
--- a/Lib/test/test_hash.py
+++ b/Lib/test/test_hash.py
@@ -113,8 +113,7 @@ class DefaultIterSeq(object):
return self.seq[index]
class HashBuiltinsTestCase(unittest.TestCase):
- hashes_to_check = [range(10),
- enumerate(range(10)),
+ hashes_to_check = [enumerate(range(10)),
iter(DefaultIterSeq()),
iter(lambda: 0, 0),
]
@@ -160,8 +159,8 @@ class StringlikeHashRandomizationTests(HashRandomizationTests):
else:
known_hash_of_obj = -1600925533
- # Randomization is disabled by default:
- self.assertEqual(self.get_hash(self.repr_), known_hash_of_obj)
+ # Randomization is enabled by default:
+ self.assertNotEqual(self.get_hash(self.repr_), known_hash_of_obj)
# It can also be disabled by setting the seed to 0:
self.assertEqual(self.get_hash(self.repr_, seed=0), known_hash_of_obj)
@@ -193,6 +192,12 @@ class BytesHashRandomizationTests(StringlikeHashRandomizationTests):
def test_empty_string(self):
self.assertEqual(hash(b""), 0)
+class MemoryviewHashRandomizationTests(StringlikeHashRandomizationTests):
+ repr_ = "memoryview(b'abc')"
+
+ def test_empty_string(self):
+ self.assertEqual(hash(memoryview(b"")), 0)
+
class DatetimeTests(HashRandomizationTests):
def get_hash_command(self, repr_):
return 'import datetime; print(hash(%s))' % repr_
@@ -213,6 +218,7 @@ def test_main():
HashBuiltinsTestCase,
StrHashRandomizationTests,
BytesHashRandomizationTests,
+ MemoryviewHashRandomizationTests,
DatetimeDateTests,
DatetimeDatetimeTests,
DatetimeTimeTests)