Skip to content

Commit 2514a91

Browse files
committed
feat(test): split up run tests
1 parent 69ab518 commit 2514a91

File tree

1 file changed

+52
-13
lines changed

1 file changed

+52
-13
lines changed

mypyc/test-data/run-weakref.test

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
# Test cases for weakrefs (compile and run)
22

33
[case testWeakrefRef]
4-
import pytest # type: ignore [import-not-found]
5-
from weakref import proxy, ref
4+
from weakref import ref
65
from mypy_extensions import mypyc_attr
76

87
@mypyc_attr(native_class=False)
98
class Object:
109
"""some random weakreffable object"""
11-
def some_meth(self) -> int:
12-
return 1
1310

1411
def test_weakref_ref():
1512
obj = Object()
@@ -18,38 +15,80 @@ def test_weakref_ref():
1815
obj = None
1916
assert r() is None, r()
2017

18+
[file driver.py]
19+
from native import test_weakref_ref
20+
21+
test_weakref_ref()
22+
23+
24+
[case testWeakrefRefWithCallback]
25+
from weakref import ref
26+
from mypy_extensions import mypyc_attr
27+
28+
@mypyc_attr(native_class=False)
29+
class Object:
30+
"""some random weakreffable object"""
31+
2132
def test_weakref_ref_with_callback():
2233
obj = Object()
2334
r = ref(obj, lambda x: x)
2435
assert r() is obj
2536
obj = None
2637
assert r() is None, r()
2738

39+
[file driver.py]
40+
from native import test_weakref_ref_with_callback
41+
42+
test_weakref_ref_with_callback()
43+
44+
45+
[case testWeakrefProxy]
46+
import pytest # type: ignore [import-not-found]
47+
from weakref import proxy
48+
from mypy_extensions import mypyc_attr
49+
50+
@mypyc_attr(native_class=False)
51+
class Object:
52+
"""some random weakreffable object"""
53+
def some_meth(self) -> int:
54+
return 1
55+
2856
def test_weakref_proxy():
2957
obj = Object()
3058
p = proxy(obj)
59+
assert obj.some_meth() == 1
3160
assert p.some_meth() == 1
3261
obj = None
3362
with pytest.raises(ReferenceError):
3463
p.some_meth()
3564

65+
[file driver.py]
66+
from native import test_weakref_proxy
67+
68+
test_weakref_proxy()
69+
70+
71+
[case testWeakrefProxyWithCallback]
72+
import pytest # type: ignore [import-not-found]
73+
from weakref import proxy
74+
from mypy_extensions import mypyc_attr
75+
76+
@mypyc_attr(native_class=False)
77+
class Object:
78+
"""some random weakreffable object"""
79+
def some_meth(self) -> int:
80+
return 1
81+
3682
def test_weakref_proxy_with_callback():
3783
obj = Object()
3884
p = proxy(obj, lambda x: x)
85+
assert obj.some_meth() == 1
3986
assert p.some_meth() == 1
4087
obj = None
4188
with pytest.raises(ReferenceError):
4289
p.some_meth()
4390

4491
[file driver.py]
45-
from native import (
46-
test_weakref_ref,
47-
test_weakref_ref_with_callback,
48-
test_weakref_proxy,
49-
test_weakref_proxy_with_callback,
50-
)
92+
from native import test_weakref_proxy_with_callback
5193

52-
test_weakref_ref()
53-
test_weakref_ref_with_callback()
54-
test_weakref_proxy()
5594
test_weakref_proxy_with_callback()

0 commit comments

Comments
 (0)