[Sqlalchemy-commits] sqlalchemy: follow the pattern set earlier in the tests
Brought to you by:
zzzeek
From: <co...@sq...> - 2011-12-11 23:14:00
|
details: http://hg.sqlalchemy.org/sqlalchemy/sqlalchemy/rev/d0e82196ab16 changeset: 7981:d0e82196ab16 user: diana date: Sun Dec 11 18:13:35 2011 -0500 description: follow the pattern set earlier in the tests diffstat: test/orm/inheritance/test_query.py | 48 ++++++++++--------------------------- 1 files changed, 13 insertions(+), 35 deletions(-) diffs (138 lines): diff -r 26120c6068af -r d0e82196ab16 test/orm/inheritance/test_query.py --- a/test/orm/inheritance/test_query.py Sun Dec 11 16:51:27 2011 -0500 +++ b/test/orm/inheritance/test_query.py Sun Dec 11 18:13:35 2011 -0500 @@ -1934,6 +1934,8 @@ @classmethod def insert_data(cls): + global p1, p2 + Parent = cls.classes.Parent Sub = cls.classes.Sub Related = cls.classes.Related @@ -1950,26 +1952,13 @@ sess.add(p2) sess.commit() - cls.expected = [ - Parent( - data='p1', - children=[ - Sub(data='s1'), - Sub(data='s2'), - Sub(data='s3')]), - Parent( - data='p2', - children=[ - Sub(data='s4'), - Sub(data='s5')])] - def test_joinedload(self): Parent = self.classes.Parent sess = Session() def go(): eq_(sess.query(Parent) .options(joinedload(Parent.children)).all(), - self.expected) + [p1, p2]) self.assert_sql_count(testing.db, go, 1) def test_contains_eager(self): @@ -1981,7 +1970,7 @@ .join(Parent.children) .options(contains_eager(Parent.children)) .order_by(Parent.data, Sub.data).all(), - self.expected) + [p1, p2]) self.assert_sql_count(testing.db, go, 1) def test_subq_through_related(self): @@ -1992,7 +1981,7 @@ eq_(sess.query(Parent) .options(subqueryload_all(Parent.children, Sub.related)) .order_by(Parent.data).all(), - self.expected) + [p1, p2]) self.assert_sql_count(testing.db, go, 3) class SubClassEagerToSubClassTest(fixtures.MappedTest): @@ -2078,6 +2067,8 @@ @classmethod def insert_data(cls): + global p1, p2 + Sub, Subparent = cls.classes.Sub, cls.classes.Subparent sess = create_session() p1 = Subparent( @@ -2090,19 +2081,6 @@ sess.add(p2) sess.flush() - cls.expected = [ - Subparent( - data='p1', - children=[ - Sub(data='s1'), - Sub(data='s2'), - Sub(data='s3')]), - Subparent( - data='p2', - children=[ - Sub(data='s4'), - Sub(data='s5')])] - def test_joinedload(self): Subparent = self.classes.Subparent @@ -2110,14 +2088,14 @@ def go(): eq_(sess.query(Subparent) .options(joinedload(Subparent.children)).all(), - self.expected) + [p1, p2]) self.assert_sql_count(testing.db, go, 1) sess.expunge_all() def go(): eq_(sess.query(Subparent) .options(joinedload("children")).all(), - self.expected) + [p1, p2]) self.assert_sql_count(testing.db, go, 1) def test_contains_eager(self): @@ -2128,7 +2106,7 @@ eq_(sess.query(Subparent) .join(Subparent.children) .options(contains_eager(Subparent.children)).all(), - self.expected) + [p1, p2]) self.assert_sql_count(testing.db, go, 1) sess.expunge_all() @@ -2136,7 +2114,7 @@ eq_(sess.query(Subparent) .join(Subparent.children) .options(contains_eager("children")).all(), - self.expected) + [p1, p2]) self.assert_sql_count(testing.db, go, 1) def test_subqueryload(self): @@ -2146,13 +2124,13 @@ def go(): eq_(sess.query(Subparent) .options(subqueryload(Subparent.children)).all(), - self.expected) + [p1, p2]) self.assert_sql_count(testing.db, go, 2) sess.expunge_all() def go(): eq_(sess.query(Subparent) .options(subqueryload("children")).all(), - self.expected) + [p1, p2]) self.assert_sql_count(testing.db, go, 2) |