Skip to content

Commit f391b3c

Browse files
gh-96478: Fix new test when run in refleak mode (GH-96615)
./python.exe -m test -R : test.test_typing would fail, apparently because the dictionary used in the @patch decorator was modified. (cherry picked from commit f0d9136) Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent 04aa15f commit f391b3c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Diff for: Lib/test/test_typing.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -4379,19 +4379,19 @@ def blah():
43794379

43804380
blah()
43814381

4382-
@patch("typing._overload_registry",
4383-
defaultdict(lambda: defaultdict(dict)))
43844382
def test_overload_on_compiled_functions(self):
4385-
# The registry starts out empty:
4386-
self.assertEqual(typing._overload_registry, {})
4387-
4388-
# This should just not fail:
4389-
overload(sum)
4390-
overload(print)
4391-
4392-
# No overloads are recorded (but, it still has a side-effect):
4393-
self.assertEqual(typing.get_overloads(sum), [])
4394-
self.assertEqual(typing.get_overloads(print), [])
4383+
with patch("typing._overload_registry",
4384+
defaultdict(lambda: defaultdict(dict))):
4385+
# The registry starts out empty:
4386+
self.assertEqual(typing._overload_registry, {})
4387+
4388+
# This should just not fail:
4389+
overload(sum)
4390+
overload(print)
4391+
4392+
# No overloads are recorded (but, it still has a side-effect):
4393+
self.assertEqual(typing.get_overloads(sum), [])
4394+
self.assertEqual(typing.get_overloads(print), [])
43954395

43964396
def set_up_overloads(self):
43974397
def blah():

0 commit comments

Comments
 (0)