summaryrefslogtreecommitdiff
path: root/test/aaa_profiling
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-02-18 15:50:37 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-02-18 15:50:37 -0500
commit3eff76c4b0c234717e6d8a157ef6883b72694927 (patch)
tree708def99d77358e61a0ab04d3386e2bdbb74fb1e /test/aaa_profiling
parent94d57374c44b49dce8531a0b0ed3116e52530c3b (diff)
downloadsqlalchemy-3eff76c4b0c234717e6d8a157ef6883b72694927.tar.gz
- add the test_expire_lots test for comparison
Diffstat (limited to 'test/aaa_profiling')
-rw-r--r--test/aaa_profiling/test_orm.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/aaa_profiling/test_orm.py b/test/aaa_profiling/test_orm.py
index 2e0cb4e44..9251e75e1 100644
--- a/test/aaa_profiling/test_orm.py
+++ b/test/aaa_profiling/test_orm.py
@@ -407,3 +407,57 @@ class AttributeOverheadTest(fixtures.MappedTest):
for child in children:
p1.children.remove(child)
go()
+
+
+class SessionTest(fixtures.MappedTest):
+ @classmethod
+ def define_tables(cls, metadata):
+ Table(
+ 'parent',
+ metadata,
+ Column('id', Integer,
+ primary_key=True, test_needs_autoincrement=True),
+ Column('data', String(20)))
+ Table(
+ 'child', metadata,
+ Column('id', Integer, primary_key=True,
+ test_needs_autoincrement=True),
+ Column(
+ 'data', String(20)), Column(
+ 'parent_id', Integer, ForeignKey('parent.id'), nullable=False))
+
+ @classmethod
+ def setup_classes(cls):
+ class Parent(cls.Basic):
+ pass
+
+ class Child(cls.Basic):
+ pass
+
+ @classmethod
+ def setup_mappers(cls):
+ Child, Parent, parent, child = (cls.classes.Child,
+ cls.classes.Parent,
+ cls.tables.parent,
+ cls.tables.child)
+
+ mapper(
+ Parent, parent, properties={
+ 'children': relationship(
+ Child,
+ backref='parent')})
+ mapper(Child, child)
+
+ def test_expire_lots(self):
+ Parent, Child = self.classes.Parent, self.classes.Child
+ obj = [Parent(
+ children=[Child() for j in range(10)]) for i in range(10)]
+
+ sess = Session()
+ sess.add_all(obj)
+ sess.flush()
+
+ @profiling.function_call_count()
+ def go():
+ sess.expire_all()
+ go()