File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ class Object:
1010 def some_meth(self) -> int:
1111 return 1
1212
13+ _callback_called_cache: dict[str, bool] = {"ref": False, "proxy": False}
14+
1315def test_weakref_ref():
1416 obj = Object()
1517 r = ref(obj)
@@ -19,10 +21,11 @@ def test_weakref_ref():
1921
2022def test_weakref_ref_with_callback():
2123 obj = Object()
22- r = ref(obj, lambda x: x )
24+ r = ref(obj, lambda x: _callback_called_cache["ref"] = True )
2325 assert r() is obj
2426 obj = None
2527 assert r() is None, r()
28+ assert _callback_called_cache["ref"] is True
2629
2730def test_weakref_proxy():
2831 obj = Object()
@@ -36,12 +39,13 @@ def test_weakref_proxy():
3639
3740def test_weakref_proxy_with_callback():
3841 obj = Object()
39- p = proxy(obj, lambda x: x )
42+ p = proxy(obj, lambda x: _callback_called_cache["proxy"] = True )
4043 assert obj.some_meth() == 1
4144 assert p.some_meth() == 1
4245 obj.some_meth()
4346 obj = None
4447 with assertRaises(ReferenceError):
4548 p.some_meth()
49+ assert _callback_called_cache["proxy"] is True
4650
4751[builtins fixtures/test-weakref.pyi]
You can’t perform that action at this time.
0 commit comments