mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
GH-84783: Make the slice object hashable (GH-101264)
This commit is contained in:
parent
5170caf305
commit
61f1e67c6f
7 changed files with 53 additions and 12 deletions
|
@ -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):
|
||||
slice(5).__hash__()
|
||||
hash(slice(1, 2, []))
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
hash(slice(4, {}))
|
||||
|
||||
def test_cmp(self):
|
||||
s1 = slice(1, 2, 3)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue