Commits

diana committed d0e8219

follow the pattern set earlier in the tests

Comments (0)

Files changed (1)

test/orm/inheritance/test_query.py

 
     @classmethod
     def insert_data(cls):
+        global p1, p2
+
         Parent = cls.classes.Parent
         Sub = cls.classes.Sub
         Related = cls.classes.Related
         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):
                     .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):
             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):
 
     @classmethod
     def insert_data(cls):
+        global p1, p2
+
         Sub, Subparent = cls.classes.Sub, cls.classes.Subparent
         sess = create_session()
         p1 = Subparent(
         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
 
         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):
             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()
             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):
         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)