Skip to content

Commit 865f333

Browse files
committed
Fix TestSingleDispatch
1 parent cac0c73 commit 865f333

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Lib/test/test_functools.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,8 @@ def _(arg):
20192019

20202020
def test_cache_invalidation(self):
20212021
from collections import UserDict
2022+
import weakref
2023+
20222024
class TracingDict(UserDict):
20232025
def __init__(self, *args, **kwargs):
20242026
super(TracingDict, self).__init__(*args, **kwargs)
@@ -2033,9 +2035,9 @@ def __setitem__(self, key, value):
20332035
self.data[key] = value
20342036
def clear(self):
20352037
self.data.clear()
2036-
_orig_wkd = functools.WeakKeyDictionary
2038+
_orig_wkd = weakref.WeakKeyDictionary
20372039
td = TracingDict()
2038-
functools.WeakKeyDictionary = lambda: td
2040+
weakref.WeakKeyDictionary = lambda: td
20392041
c = collections.abc
20402042
@functools.singledispatch
20412043
def g(arg):
@@ -2116,7 +2118,7 @@ class X:
21162118
self.assertEqual(g(l), "list")
21172119
g._clear_cache()
21182120
self.assertEqual(len(td), 0)
2119-
functools.WeakKeyDictionary = _orig_wkd
2121+
weakref.WeakKeyDictionary = _orig_wkd
21202122

21212123

21222124
if __name__ == '__main__':

0 commit comments

Comments
 (0)