(self)
| 1209 | self.assertIs(r(), None) |
| 1210 | |
| 1211 | def test_callback_when_object_dead(self): |
| 1212 | # Test callback behaviour when object dies first. |
| 1213 | C = self._subclass() |
| 1214 | calls = [] |
| 1215 | def cb(arg): |
| 1216 | calls.append(arg) |
| 1217 | o = C(1) |
| 1218 | r = weakref.WeakMethod(o.some_method, cb) |
| 1219 | del o |
| 1220 | gc.collect() |
| 1221 | self.assertEqual(calls, [r]) |
| 1222 | # Callback is only called once. |
| 1223 | C.some_method = Object.some_method |
| 1224 | gc.collect() |
| 1225 | self.assertEqual(calls, [r]) |
| 1226 | |
| 1227 | def test_callback_when_method_dead(self): |
| 1228 | # Test callback behaviour when method dies first. |
nothing calls this directly
no test coverage detected