Skip to content

Commit 2bc82af

Browse files
committed
refactor test case with recursive __missing__ invoked
1 parent e17b229 commit 2bc82af

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Lib/test/test_defaultdict.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,16 @@ def default_factory():
195195
nonlocal count
196196
nonlocal test_dict
197197
count += 1
198+
local_count = count
198199
if count == 1:
199-
test_dict[key] = "set_value"
200-
return "default_factory_value"
200+
test_dict[key]
201+
return local_count
201202

202203
test_dict = defaultdict(default_factory)
203204

204-
self.assertEqual(test_dict[key], "set_value")
205+
self.assertEqual(count, 0)
206+
self.assertEqual(test_dict[key], 2)
207+
self.assertEqual(count, 2)
205208

206209
if __name__ == "__main__":
207210
unittest.main()

0 commit comments

Comments
 (0)