Skip to content

Commit b909e49

Browse files
committed
Test checks that created dict is not modified
1 parent 3a85298 commit b909e49

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Lib/test/test_dict.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1792,17 +1792,23 @@ def test_fromkeys(self):
17921792
frozendict(a=None, b=None, c=None))
17931793

17941794
# Subclass which overrides the constructor
1795+
created = None
17951796
class FrozenDictSubclass(frozendict):
17961797
def __new__(self):
1797-
return frozendict(x=1)
1798+
nonlocal created
1799+
created = frozendict(x=1)
1800+
return created
17981801

17991802
fd = FrozenDictSubclass.fromkeys("abc")
18001803
self.assertEqual(fd, frozendict(x=1, a=None, b=None, c=None))
18011804
self.assertEqual(type(fd), FrozenDictSubclass)
1805+
self.assertEqual(created, frozendict(x=1))
18021806

1807+
created = None
18031808
fd = FrozenDictSubclass.fromkeys(frozendict(y=2))
18041809
self.assertEqual(fd, frozendict(x=1, y=None))
18051810
self.assertEqual(type(fd), FrozenDictSubclass)
1811+
self.assertEqual(created, frozendict(x=1))
18061812

18071813
# Subclass which doesn't override the constructor
18081814
class FrozenDictSubclass2(frozendict):

0 commit comments

Comments
 (0)