mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Update test_defaultdict.py from 3.14.3
This commit is contained in:
committed by
Jeong, YunWon
parent
743780f868
commit
9d7387798c
18
Lib/test/test_defaultdict.py
vendored
18
Lib/test/test_defaultdict.py
vendored
@@ -186,5 +186,23 @@ class TestDefaultDict(unittest.TestCase):
|
||||
with self.assertRaises(TypeError):
|
||||
i |= None
|
||||
|
||||
def test_factory_conflict_with_set_value(self):
|
||||
key = "conflict_test"
|
||||
count = 0
|
||||
|
||||
def default_factory():
|
||||
nonlocal count
|
||||
count += 1
|
||||
local_count = count
|
||||
if count == 1:
|
||||
test_dict[key]
|
||||
return local_count
|
||||
|
||||
test_dict = defaultdict(default_factory)
|
||||
|
||||
self.assertEqual(count, 0)
|
||||
self.assertEqual(test_dict[key], 2)
|
||||
self.assertEqual(count, 2)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user