Here are the examples of the python api sqlalchemy.testing.util.gc_collect taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
104 Examples
3
Source : test_memusage.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def assert_no_mappers():
clear_mappers()
gc_collect()
assert len(_mapper_registry) == 0
class EnsureZeroed(fixtures.ORMTest):
3
Source : test_memusage.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_orm_objects_from_query(self):
User, Address = self.classes("User", "Address")
configure_mappers()
s = Session()
def generate():
objects = s.query(User).filter(User.id == 7).all()
gc_collect()
return objects
@assert_cycles()
def go():
generate()
go()
def test_orm_objects_from_query_w_selectinload(self):
3
Source : test_memusage.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_orm_objects_from_query_w_selectinload(self):
User, Address = self.classes("User", "Address")
s = Session()
def generate():
objects = s.query(User).options(selectinload(User.addresses)).all()
gc_collect()
return objects
@assert_cycles()
def go():
generate()
go()
def test_selectinload_option_unbound(self):
3
Source : test_memusage.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_orm_objects_from_query_w_joinedload(self):
User, Address = self.classes("User", "Address")
s = Session()
def generate():
objects = s.query(User).options(joinedload(User.addresses)).all()
gc_collect()
return objects
@assert_cycles()
def go():
generate()
go()
def test_query_filtered(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_subclass(self):
class SubTarget(self.Target):
pass
st = SubTarget()
st.dispatch.some_event(1, 2)
del st
del SubTarget
gc_collect()
eq_(self.Target.__subclasses__(), [])
class ListenOverrideTest(fixtures.TestBase):
3
Source : test_utils.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_cleanout_elements(self):
class Foo(object):
pass
f1, f2, f3 = Foo(), Foo(), Foo()
w = WeakSequence([f1, f2, f3])
eq_(len(w), 3)
eq_(len(w._storage), 3)
del f2
gc_collect()
eq_(len(w), 2)
eq_(len(w._storage), 2)
@testing.requires.predictable_gc
3
Source : test_utils.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_cleanout_appended(self):
class Foo(object):
pass
f1, f2, f3 = Foo(), Foo(), Foo()
w = WeakSequence()
w.append(f1)
w.append(f2)
w.append(f3)
eq_(len(w), 3)
eq_(len(w._storage), 3)
del f2
gc_collect()
eq_(len(w), 2)
eq_(len(w._storage), 2)
class OrderedDictTest(fixtures.TestBase):
3
Source : test_clsregistry.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_same_module_same_name(self):
base = weakref.WeakValueDictionary()
f1 = MockClass(base, "foo.bar.Foo")
f2 = MockClass(base, "foo.bar.Foo")
clsregistry.add_class("Foo", f1)
gc_collect()
assert_raises_message(
exc.SAWarning,
"This declarative base already contains a class with the "
"same class name and module name as foo.bar.Foo, and "
"will be replaced in the string-lookup table.",
clsregistry.add_class,
"Foo",
f2,
)
def test_resolve(self):
3
Source : test_clsregistry.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_resolve(self):
base = weakref.WeakValueDictionary()
f1 = MockClass(base, "foo.bar.Foo")
f2 = MockClass(base, "foo.alt.Foo")
clsregistry.add_class("Foo", f1)
clsregistry.add_class("Foo", f2)
name_resolver, resolver = clsregistry._resolver(f1, MockProp())
gc_collect()
is_(resolver("foo.bar.Foo")(), f1)
is_(resolver("foo.alt.Foo")(), f2)
is_(name_resolver("foo.bar.Foo")(), f1)
is_(name_resolver("foo.alt.Foo")(), f2)
def test_fragment_resolve(self):
3
Source : test_clsregistry.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_fragment_resolve(self):
base = weakref.WeakValueDictionary()
f1 = MockClass(base, "foo.bar.Foo")
f2 = MockClass(base, "foo.alt.Foo")
f3 = MockClass(base, "bat.alt.Hoho")
clsregistry.add_class("Foo", f1)
clsregistry.add_class("Foo", f2)
clsregistry.add_class("HoHo", f3)
name_resolver, resolver = clsregistry._resolver(f1, MockProp())
gc_collect()
is_(resolver("bar.Foo")(), f1)
is_(resolver("alt.Foo")(), f2)
is_(name_resolver("bar.Foo")(), f1)
is_(name_resolver("alt.Foo")(), f2)
def test_fragment_ambiguous(self):
3
Source : test_clsregistry.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_dupe_classes_back_to_one(self):
base = weakref.WeakValueDictionary()
f1 = MockClass(base, "foo.bar.Foo")
f2 = MockClass(base, "foo.alt.Foo")
clsregistry.add_class("Foo", f1)
clsregistry.add_class("Foo", f2)
del f2
gc_collect()
# registry restores itself to just the one class
name_resolver, resolver = clsregistry._resolver(f1, MockProp())
f_resolver = resolver("Foo")
is_(f_resolver(), f1)
f_resolver = name_resolver("Foo")
is_(f_resolver(), f1)
def test_dupe_classes_cleanout(self):
3
Source : test_clsregistry.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_module_reg_cleanout_two_sub(self):
base = weakref.WeakValueDictionary()
f1 = MockClass(base, "foo.bar.Foo")
clsregistry.add_class("Foo", f1)
reg = base["_sa_module_registry"]
f2 = MockClass(base, "foo.alt.Bar")
clsregistry.add_class("Bar", f2)
assert reg["foo"]["bar"]
del f1
gc_collect()
assert "bar" not in reg["foo"]
assert "alt" in reg["foo"]
del f2
gc_collect()
assert "foo" not in reg.contents
def test_module_reg_cleanout_sub_to_base(self):
3
Source : test_clsregistry.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_module_reg_cleanout_sub_to_base(self):
base = weakref.WeakValueDictionary()
f3 = MockClass(base, "bat.bar.Hoho")
clsregistry.add_class("Hoho", f3)
reg = base["_sa_module_registry"]
assert reg["bat"]["bar"]
del f3
gc_collect()
assert "bat" not in reg
def test_module_reg_cleanout_cls_to_base(self):
3
Source : test_clsregistry.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_module_reg_cleanout_cls_to_base(self):
base = weakref.WeakValueDictionary()
f4 = MockClass(base, "single.Blat")
clsregistry.add_class("Blat", f4)
reg = base["_sa_module_registry"]
assert reg["single"]
del f4
gc_collect()
assert "single" not in reg
3
Source : test_reflection.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_cls_not_strong_ref(self):
class User(decl.DeferredReflection, fixtures.ComparableEntity, Base):
__tablename__ = "users"
class Address(
decl.DeferredReflection, fixtures.ComparableEntity, Base
):
__tablename__ = "addresses"
eq_(len(_DeferredMapperConfig._configs), 2)
del Address
gc_collect()
eq_(len(_DeferredMapperConfig._configs), 1)
decl.DeferredReflection.prepare(testing.db)
assert not _DeferredMapperConfig._configs
class DeferredSecondaryReflectionTest(DeferredReflectBase):
3
Source : test_associationproxy.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_weak_identity_map(self):
mapper(
Parent, self.parents, properties=dict(children=relationship(Child))
)
mapper(Child, self.children)
session = create_session()
def add_child(parent_name, child_name):
parent = session.query(Parent).filter_by(name=parent_name).one()
parent.kids.append(child_name)
add_child("p1", "c1")
gc_collect()
add_child("p1", "c2")
session.flush()
p = session.query(Parent).filter_by(name="p1").one()
assert set(p.kids) == set(["c1", "c2"]), p.kids
def test_copy(self):
3
Source : test_associationproxy.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_copy(self):
mapper(
Parent, self.parents, properties=dict(children=relationship(Child))
)
mapper(Child, self.children)
p = Parent("p1")
p.kids.extend(["c1", "c2"])
p_copy = copy.copy(p)
del p
gc_collect()
assert set(p_copy.kids) == set(["c1", "c2"]), p_copy.kids
def test_pickle_list(self):
3
Source : test_associationproxy.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_plain_collection_gc(self):
A, B = self.classes("A", "B")
s = Session(testing.db)
a1 = s.query(A).filter_by(id=1).one()
a1bs = a1.bs # noqa
del a1
gc_collect()
assert (A, (1,), None) not in s.identity_map
@testing.fails("dynamic relationship strong references parent")
3
Source : test_associationproxy.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_dynamic_collection_gc(self):
A, B = self.classes("A", "B")
s = Session(testing.db)
a1 = s.query(A).filter_by(id=1).one()
a1bs = a1.b_dyn # noqa
del a1
gc_collect()
# also fails, AppenderQuery holds onto parent
assert (A, (1,), None) not in s.identity_map
@testing.fails("association proxy strong references parent")
3
Source : test_associationproxy.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_associated_collection_gc(self):
A, B = self.classes("A", "B")
s = Session(testing.db)
a1 = s.query(A).filter_by(id=1).one()
a1bs = a1.b_data # noqa
del a1
gc_collect()
assert (A, (1,), None) not in s.identity_map
@testing.fails("association proxy strong references parent")
3
Source : test_associationproxy.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_associated_dynamic_gc(self):
A, B = self.classes("A", "B")
s = Session(testing.db)
a1 = s.query(A).filter_by(id=1).one()
a1bs = a1.b_dynamic_data # noqa
del a1
gc_collect()
assert (A, (1,), None) not in s.identity_map
def test_plain_collection_iterate(self):
3
Source : test_associationproxy.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_plain_collection_iterate(self):
A, B = self.classes("A", "B")
s = Session(testing.db)
a1 = s.query(A).filter_by(id=1).one()
a1bs = a1.bs
del a1
gc_collect()
assert len(a1bs) == 2
def test_dynamic_collection_iterate(self):
3
Source : test_associationproxy.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_dynamic_collection_iterate(self):
A, B = self.classes("A", "B")
s = Session(testing.db)
a1 = s.query(A).filter_by(id=1).one()
a1bs = a1.b_dyn # noqa
del a1
gc_collect()
assert len(list(a1bs)) == 2
def test_associated_collection_iterate(self):
3
Source : test_associationproxy.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_associated_collection_iterate(self):
A, B = self.classes("A", "B")
s = Session(testing.db)
a1 = s.query(A).filter_by(id=1).one()
a1bs = a1.b_data
del a1
gc_collect()
assert len(a1bs) == 2
def test_associated_dynamic_iterate(self):
3
Source : test_associationproxy.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_associated_dynamic_iterate(self):
A, B = self.classes("A", "B")
s = Session(testing.db)
a1 = s.query(A).filter_by(id=1).one()
a1bs = a1.b_dynamic_data
del a1
gc_collect()
assert len(a1bs) == 2
3
Source : test_attributes.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_state_gc(self):
"""test that InstanceState always has a dict, even after host
object gc'ed."""
class Foo(object):
pass
instrumentation.register_class(Foo)
f = Foo()
state = attributes.instance_state(f)
f.bar = "foo"
eq_(state.dict, {"bar": "foo", state.manager.STATE_ATTR: state})
del f
gc_collect()
assert state.obj() is None
assert state.dict == {}
@testing.requires.predictable_gc
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_instrument_event_auto_remove(self):
class Bar(object):
pass
dispatch = instrumentation._instrumentation_factory.dispatch
assert not dispatch.attribute_instrument
event.listen(Bar, "attribute_instrument", lambda: None)
eq_(len(dispatch.attribute_instrument), 1)
del Bar
gc_collect()
assert not dispatch.attribute_instrument
def test_deferred_instrument_event_subclass_propagate(self):
3
Source : test_hasparent.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_stale_state_positive_gc(self):
User = self.classes.User
s, u1, a1 = self._fixture()
s.expunge(u1)
del u1
gc_collect()
u1 = s.query(User).first()
u1.addresses.remove(a1)
self._assert_not_hasparent(a1)
@testing.requires.updateable_autoincrement_pks
3
Source : test_session.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_deferred_expression_obj_was_gced(self):
User, Address = self.classes("User", "Address")
sess = create_session(autoflush=True, autocommit=False)
u = User(name="ed", addresses=[Address(email_address="foo")])
sess.add(u)
sess.commit()
sess.close()
u = sess.query(User).get(u.id)
q = sess.query(Address).filter(Address.user == u)
del u
gc_collect()
eq_(q.one(), Address(email_address="foo"))
def test_deferred_expression_favors_immediate(self):
3
Source : test_session.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_move_gc_session_persistent_dirty(self):
sess, u1 = self._persistent_fixture()
u1.name = "edchanged"
self._assert_cycle(u1)
self._assert_modified(u1)
del sess
gc_collect()
self._assert_cycle(u1)
s2 = Session()
s2.add(u1)
self._assert_cycle(u1)
self._assert_modified(u1)
def test_persistent_dirty_to_expired(self):
3
Source : test_memusage.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def assert_no_mappers():
clear_mappers()
gc_collect()
class EnsureZeroed(fixtures.ORMTest):
3
Source : test_memusage.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_orm_objects_from_query(self):
User, Address = self.classes("User", "Address")
configure_mappers()
s = fixture_session()
def generate():
objects = s.query(User).filter(User.id == 7).all()
gc_collect()
return objects
@assert_cycles()
def go():
generate()
go()
def test_orm_objects_from_query_w_selectinload(self):
3
Source : test_memusage.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_orm_objects_from_query_w_selectinload(self):
User, Address = self.classes("User", "Address")
s = fixture_session()
def generate():
objects = s.query(User).options(selectinload(User.addresses)).all()
gc_collect()
return objects
@assert_cycles()
def go():
generate()
go()
def test_selectinload_option_unbound(self):
3
Source : test_memusage.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_orm_objects_from_query_w_joinedload(self):
User, Address = self.classes("User", "Address")
s = fixture_session()
def generate():
objects = s.query(User).options(joinedload(User.addresses)).all()
gc_collect()
return objects
@assert_cycles()
def go():
generate()
go()
def test_query_filtered(self):
3
Source : test_events.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_subclass(self):
class SubTarget(self.Target):
pass
st = SubTarget()
st.dispatch.some_event(1, 2)
del st
del SubTarget
gc_collect()
eq_(self.Target.__subclasses__(), [])
class ListenOverrideTest(TearDownLocalEventsFixture, fixtures.TestBase):
3
Source : test_utils.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_cleanout_elements(self):
class Foo:
pass
f1, f2, f3 = Foo(), Foo(), Foo()
w = WeakSequence([f1, f2, f3])
eq_(len(w), 3)
eq_(len(w._storage), 3)
del f2
gc_collect()
eq_(len(w), 2)
eq_(len(w._storage), 2)
@testing.requires.predictable_gc
3
Source : test_utils.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_cleanout_appended(self):
class Foo:
pass
f1, f2, f3 = Foo(), Foo(), Foo()
w = WeakSequence()
w.append(f1)
w.append(f2)
w.append(f3)
eq_(len(w), 3)
eq_(len(w._storage), 3)
del f2
gc_collect()
eq_(len(w), 2)
eq_(len(w._storage), 2)
class MergeListsWOrderingTest(fixtures.TestBase):
3
Source : test_reflection.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_cls_not_strong_ref(self):
class User(DeferredReflection, fixtures.ComparableEntity, Base):
__tablename__ = "users"
class Address(DeferredReflection, fixtures.ComparableEntity, Base):
__tablename__ = "addresses"
eq_(len(_DeferredMapperConfig._configs), 2)
del Address
gc_collect()
eq_(len(_DeferredMapperConfig._configs), 1)
DeferredReflection.prepare(testing.db)
assert not _DeferredMapperConfig._configs
class DeferredSecondaryReflectionTest(DeferredReflectBase):
3
Source : test_associationproxy.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_copy(self):
self.mapper_registry.map_imperatively(
Parent,
self.tables.parents,
properties=dict(children=relationship(Child)),
)
self.mapper_registry.map_imperatively(Child, self.tables.children)
p = Parent("p1")
p.kids.extend(["c1", "c2"])
p_copy = copy.copy(p)
del p
gc_collect()
assert set(p_copy.kids) == set(["c1", "c2"]), p_copy.kids
def test_pickle_list(self):
3
Source : test_clsregistry.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_resolve(self):
base = registry()
f1 = MockClass(base, "foo.bar.Foo")
f2 = MockClass(base, "foo.alt.Foo")
clsregistry.add_class("Foo", f1, base._class_registry)
clsregistry.add_class("Foo", f2, base._class_registry)
name_resolver, resolver = clsregistry._resolver(f1, MockProp())
gc_collect()
is_(resolver("foo.bar.Foo")(), f1)
is_(resolver("foo.alt.Foo")(), f2)
is_(name_resolver("foo.bar.Foo")(), f1)
is_(name_resolver("foo.alt.Foo")(), f2)
def test_fragment_resolve(self):
3
Source : test_clsregistry.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_fragment_resolve(self):
base = registry()
f1 = MockClass(base, "foo.bar.Foo")
f2 = MockClass(base, "foo.alt.Foo")
f3 = MockClass(base, "bat.alt.Hoho")
clsregistry.add_class("Foo", f1, base._class_registry)
clsregistry.add_class("Foo", f2, base._class_registry)
clsregistry.add_class("HoHo", f3, base._class_registry)
name_resolver, resolver = clsregistry._resolver(f1, MockProp())
gc_collect()
is_(resolver("bar.Foo")(), f1)
is_(resolver("alt.Foo")(), f2)
is_(name_resolver("bar.Foo")(), f1)
is_(name_resolver("alt.Foo")(), f2)
def test_fragment_ambiguous(self):
3
Source : test_clsregistry.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_dupe_classes_back_to_one(self):
base = registry()
f1 = MockClass(base, "foo.bar.Foo")
f2 = MockClass(base, "foo.alt.Foo")
clsregistry.add_class("Foo", f1, base._class_registry)
clsregistry.add_class("Foo", f2, base._class_registry)
del f2
gc_collect()
# registry restores itself to just the one class
name_resolver, resolver = clsregistry._resolver(f1, MockProp())
f_resolver = resolver("Foo")
is_(f_resolver(), f1)
f_resolver = name_resolver("Foo")
is_(f_resolver(), f1)
def test_dupe_classes_cleanout(self):
3
Source : test_clsregistry.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_module_reg_cleanout_two_sub(self):
base = registry()
f1 = MockClass(base, "foo.bar.Foo")
clsregistry.add_class("Foo", f1, base._class_registry)
reg = base._class_registry["_sa_module_registry"]
f2 = MockClass(base, "foo.alt.Bar")
clsregistry.add_class("Bar", f2, base._class_registry)
assert reg["foo"]["bar"]
del f1
gc_collect()
assert "bar" not in reg["foo"]
assert "alt" in reg["foo"]
del f2
gc_collect()
assert "foo" not in reg.contents
def test_module_reg_cleanout_sub_to_base(self):
3
Source : test_clsregistry.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_module_reg_cleanout_sub_to_base(self):
base = registry()
f3 = MockClass(base, "bat.bar.Hoho")
clsregistry.add_class("Hoho", f3, base._class_registry)
reg = base._class_registry["_sa_module_registry"]
assert reg["bat"]["bar"]
del f3
gc_collect()
assert "bat" not in reg
def test_module_reg_cleanout_cls_to_base(self):
3
Source : test_clsregistry.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_module_reg_cleanout_cls_to_base(self):
base = registry()
f4 = MockClass(base, "single.Blat")
clsregistry.add_class("Blat", f4, base._class_registry)
reg = base._class_registry["_sa_module_registry"]
assert reg["single"]
del f4
gc_collect()
assert "single" not in reg
3
Source : test_attributes.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_state_gc(self):
"""test that InstanceState always has a dict, even after host
object gc'ed."""
class Foo:
pass
instrumentation.register_class(Foo)
f = Foo()
state = attributes.instance_state(f)
f.bar = "foo"
eq_(state.dict, {"bar": "foo", state.manager.STATE_ATTR: state})
del f
gc_collect()
assert state.obj() is None
assert state.dict == {}
@testing.requires.predictable_gc
3
Source : test_events.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_instrument_event_auto_remove(self):
class Bar:
pass
dispatch = instrumentation._instrumentation_factory.dispatch
assert not dispatch.attribute_instrument
event.listen(Bar, "attribute_instrument", lambda: None)
eq_(len(dispatch.attribute_instrument), 1)
del Bar
gc_collect()
assert not dispatch.attribute_instrument
def test_deferred_instrument_event_subclass_propagate(self):
3
Source : test_session.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_deferred_expression_obj_was_gced(self):
User, Address = self.classes("User", "Address")
sess = fixture_session(autoflush=True, expire_on_commit=False)
u = User(name="ed", addresses=[Address(email_address="foo")])
sess.add(u)
sess.commit()
sess.close()
u = sess.get(User, u.id)
q = sess.query(Address).filter(Address.user == u)
del u
gc_collect()
eq_(q.one(), Address(email_address="foo"))
def test_deferred_expression_favors_immediate(self):
3
Source : test_session.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_move_gc_session_persistent_dirty(self):
sess, u1 = self._persistent_fixture(gc_collect=True)
u1.name = "edchanged"
self._assert_cycle(u1)
self._assert_modified(u1)
del sess
gc_collect()
self._assert_cycle(u1)
s2 = Session(testing.db)
s2.add(u1)
self._assert_cycle(u1)
self._assert_modified(u1)
def test_persistent_dirty_to_expired(self):
0
Source : test_memusage.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def assert_cycles(expected=0):
def decorate(fn):
def go():
fn() # warmup, configure mappers, caches, etc.
gc_collect()
gc_collect()
gc_collect() # multiple calls seem to matter
# gc.set_debug(gc.DEBUG_COLLECTABLE)
try:
return fn() # run for real
finally:
unreachable = gc_collect()
assert unreachable < = expected
gc_collect()
return go
return decorate
def profile_memory(
See More Examples