summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
diff options
context:
space:
mode:
authorYurii Karabas <1998uriyyo@gmail.com>2020-11-19 16:17:38 (GMT)
committerGitHub <noreply@github.com>2020-11-19 16:17:38 (GMT)
commit1b54077ff6f5c1379e097e9f8e8648da9826d6ec (patch)
treec8de68da519cd471ef2ea002b8a1f51fa97a8203 /Lib/test/test_typing.py
parentb437aa83f9374b86b7756705e8dc83b72a99e037 (diff)
downloadcpython-1b54077ff6f5c1379e097e9f8e8648da9826d6ec.zip
cpython-1b54077ff6f5c1379e097e9f8e8648da9826d6ec.tar.gz
cpython-1b54077ff6f5c1379e097e9f8e8648da9826d6ec.tar.bz2
bpo-42345: Fix hash implementation of typing.Literal (GH-23383)
Fix hash implementation of `typing.Literal`. Update docs regarding `typing.Litaral` caching. Base implementation was done in PR #23294.
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r--Lib/test/test_typing.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 7deba0d..8ffc7f4 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -569,6 +569,11 @@ class LiteralTests(BaseTestCase):
self.assertEqual(Literal[1, 2], Literal[2, 1])
self.assertEqual(Literal[1, 2, 3], Literal[1, 2, 3, 3])
+ def test_hash(self):
+ self.assertEqual(hash(Literal[1]), hash(Literal[1]))
+ self.assertEqual(hash(Literal[1, 2]), hash(Literal[2, 1]))
+ self.assertEqual(hash(Literal[1, 2, 3]), hash(Literal[1, 2, 3, 3]))
+
def test_args(self):
self.assertEqual(Literal[1, 2, 3].__args__, (1, 2, 3))
self.assertEqual(Literal[1, 2, 3, 3].__args__, (1, 2, 3))