| 191 | "callback not called the right number of times") |
| 192 | |
| 193 | def test_multiple_selfref_callbacks(self): |
| 194 | # Make sure all references are invalidated before callbacks are called |
| 195 | # |
| 196 | # What's important here is that we're using the first |
| 197 | # reference in the callback invoked on the second reference |
| 198 | # (the most recently created ref is cleaned up first). This |
| 199 | # tests that all references to the object are invalidated |
| 200 | # before any of the callbacks are invoked, so that we only |
| 201 | # have one invocation of _weakref.c:cleanup_helper() active |
| 202 | # for a particular object at a time. |
| 203 | # |
| 204 | def callback(object, self=self): |
| 205 | self.ref() |
| 206 | c = C() |
| 207 | self.ref = weakref.ref(c, callback) |
| 208 | ref1 = weakref.ref(c, callback) |
| 209 | del c |
| 210 | |
| 211 | def test_constructor_kwargs(self): |
| 212 | c = C() |