diff options
author | Furkan Onder <furkanonder@protonmail.com> | 2023-02-19 00:22:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-19 00:22:02 (GMT) |
commit | 61f1e67c6fcbf80eb9be2b75f7d62954e28c89e6 (patch) | |
tree | 74e32f1ed356fa4cb6cf6013c2cf2aca10046ff3 /Lib/test/test_slice.py | |
parent | 5170caf3059fdacc92d7370eecb9fe4f0c5a1c76 (diff) | |
download | cpython-61f1e67c6fcbf80eb9be2b75f7d62954e28c89e6.zip cpython-61f1e67c6fcbf80eb9be2b75f7d62954e28c89e6.tar.gz cpython-61f1e67c6fcbf80eb9be2b75f7d62954e28c89e6.tar.bz2 |
GH-84783: Make the slice object hashable (GH-101264)
Diffstat (limited to 'Lib/test/test_slice.py')
-rw-r--r-- | Lib/test/test_slice.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/test/test_slice.py b/Lib/test/test_slice.py index 03fde32..c35a229 100644 --- a/Lib/test/test_slice.py +++ b/Lib/test/test_slice.py @@ -80,10 +80,16 @@ class SliceTest(unittest.TestCase): self.assertEqual(repr(slice(1, 2, 3)), "slice(1, 2, 3)") def test_hash(self): - # Verify clearing of SF bug #800796 - self.assertRaises(TypeError, hash, slice(5)) + self.assertEqual(hash(slice(5)), slice(5).__hash__()) + self.assertEqual(hash(slice(1, 2)), slice(1, 2).__hash__()) + self.assertEqual(hash(slice(1, 2, 3)), slice(1, 2, 3).__hash__()) + self.assertNotEqual(slice(5), slice(6)) + + with self.assertRaises(TypeError): + hash(slice(1, 2, [])) + with self.assertRaises(TypeError): - slice(5).__hash__() + hash(slice(4, {})) def test_cmp(self): s1 = slice(1, 2, 3) |