test that InstanceState always has a dict, even after host object gc'ed.
(self)
| 322 | |
| 323 | @testing.requires.predictable_gc |
| 324 | def test_state_gc(self): |
| 325 | """test that InstanceState always has a dict, even after host |
| 326 | object gc'ed.""" |
| 327 | |
| 328 | class Foo: |
| 329 | pass |
| 330 | |
| 331 | instrumentation.register_class(Foo) |
| 332 | f = Foo() |
| 333 | state = attributes.instance_state(f) |
| 334 | f.bar = "foo" |
| 335 | eq_(state.dict, {"bar": "foo", state.manager.STATE_ATTR: state}) |
| 336 | del f |
| 337 | gc_collect() |
| 338 | assert state.obj() is None |
| 339 | assert state.dict == {} |
| 340 | |
| 341 | @testing.requires.predictable_gc |
| 342 | def test_object_dereferenced_error(self): |