Skip to content

Commit 2667ae8

Browse files
test callback is called
1 parent fe03dd6 commit 2667ae8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mypyc/test-data/run-weakref.test

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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+
1315
def test_weakref_ref():
1416
obj = Object()
1517
r = ref(obj)
@@ -19,10 +21,11 @@ def test_weakref_ref():
1921

2022
def 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

2730
def test_weakref_proxy():
2831
obj = Object()
@@ -36,12 +39,13 @@ def test_weakref_proxy():
3639

3740
def 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]

0 commit comments

Comments
 (0)