File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -1408,3 +1408,45 @@ class TestOverload:
14081408
14091409 def __mypyc_generator_helper__(self, x: Any) -> Any:
14101410 return x
1411+
1412+ [case testMypycAttrSupportsWeakref]
1413+ import weakref
1414+ from mypy_extensions import mypyc_attr
1415+
1416+ @mypyc_attr(supports_weakref=True)
1417+ class WeakrefClass:
1418+ pass
1419+
1420+ obj = WeakrefClass()
1421+ ref = weakref.ref(obj)
1422+ assert ref() is obj
1423+
1424+ [case testMypycAttrSupportsWeakrefInheritance]
1425+ import weakref
1426+ from mypy_extensions import mypyc_attr
1427+
1428+ @mypyc_attr(supports_weakref=True)
1429+ class WeakrefClass:
1430+ pass
1431+
1432+ class WeakrefInheritor(WeakrefClass):
1433+ pass
1434+
1435+ obj = WeakrefInheritor()
1436+ ref = weakref.ref(obj)
1437+ assert ref() is obj
1438+
1439+ [case testMypycAttrSupportsWeakrefSubclass]
1440+ import weakref
1441+ from mypy_extensions import mypyc_attr
1442+
1443+ class NativeClass:
1444+ pass
1445+
1446+ @mypyc_attr(supports_weakref=True)
1447+ class WeakrefSubclass(NativeClass):
1448+ pass
1449+
1450+ obj = WeakrefSubclass()
1451+ ref = weakref.ref(obj)
1452+ assert ref() is obj
You can’t perform that action at this time.
0 commit comments