MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_state_gc

Method test_state_gc

test/orm/test_attributes.py:324–339  ·  view source on GitHub ↗

test that InstanceState always has a dict, even after host object gc'ed.

(self)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 2

eq_Function · 0.90
FooClass · 0.70

Tested by

no test coverage detected