Skip to content

Commit a55a54e

Browse files
committed
Add test_hash_cpython()
1 parent abaa568 commit a55a54e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lib/test/test_dict.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,6 +1918,20 @@ def test_hash(self):
19181918
with self.assertRaisesRegex(TypeError, "unhashable type: 'list'"):
19191919
hash(fd)
19201920

1921+
@support.cpython_only
1922+
def test_hash_cpython(self):
1923+
# Check that hash(frozendict) implementation is:
1924+
# hash(frozenset(fd.items()))
1925+
for fd in (
1926+
frozendict(),
1927+
frozendict(x=1, y=2),
1928+
frozendict(y=2, x=1),
1929+
frozendict(a=False, b=True, c=True),
1930+
frozendict.fromkeys('abc'),
1931+
):
1932+
with self.subTest(fd=fd):
1933+
self.assertEqual(hash(fd), hash(frozenset(fd.items())))
1934+
19211935
def test_fromkeys(self):
19221936
self.assertEqual(frozendict.fromkeys('abc'),
19231937
frozendict(a=None, b=None, c=None))

0 commit comments

Comments
 (0)