(self)
| 213 | self.assertRaises(TypeError, weakref.ref, c, callback=None) |
| 214 | |
| 215 | def test_proxy_ref(self): |
| 216 | o = C() |
| 217 | o.bar = 1 |
| 218 | ref1 = weakref.proxy(o, self.callback) |
| 219 | ref2 = weakref.proxy(o, self.callback) |
| 220 | del o |
| 221 | gc_collect() # For PyPy or other GCs. |
| 222 | |
| 223 | def check(proxy): |
| 224 | proxy.bar |
| 225 | |
| 226 | self.assertRaises(ReferenceError, check, ref1) |
| 227 | self.assertRaises(ReferenceError, check, ref2) |
| 228 | ref3 = weakref.proxy(C()) |
| 229 | gc_collect() # For PyPy or other GCs. |
| 230 | self.assertRaises(ReferenceError, bool, ref3) |
| 231 | self.assertEqual(self.cbcalled, 2) |
| 232 | |
| 233 | @support.cpython_only |
| 234 | def test_proxy_repr(self): |
nothing calls this directly
no test coverage detected