From 6eaff44db8ed456c7b3037cfd3464804e7bc1d1c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 30 May 2009 19:56:08 +0000 Subject: [PATCH] some nextisms --- test/orm/generative.py | 15 ++++++++++++++- test/orm/inheritance/poly_linked_list.py | 15 ++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/test/orm/generative.py b/test/orm/generative.py index 9952367414..9912b7b23d 100644 --- a/test/orm/generative.py +++ b/test/orm/generative.py @@ -64,9 +64,14 @@ class GenerativeQueryTest(_base.MappedTest): assert sess.query(func.min(foo.c.bar)).filter(foo.c.bar<30).one() == (0,) assert sess.query(func.max(foo.c.bar)).filter(foo.c.bar<30).one() == (29,) + # Py3K + #assert query.filter(foo.c.bar<30).values(sa.func.max(foo.c.bar)).__next__()[0] == 29 + #assert query.filter(foo.c.bar<30).values(sa.func.max(foo.c.bar)).__next__()[0] == 29 + # Py2K assert query.filter(foo.c.bar<30).values(sa.func.max(foo.c.bar)).next()[0] == 29 assert query.filter(foo.c.bar<30).values(sa.func.max(foo.c.bar)).next()[0] == 29 - + # end Py2K + @testing.resolve_artifact_names def test_aggregate_1(self): if (testing.against('mysql') and @@ -89,10 +94,18 @@ class GenerativeQueryTest(_base.MappedTest): def test_aggregate_3(self): query = create_session().query(Foo) + # Py3K + #avg_f = query.filter(foo.c.bar<30).values(sa.func.avg(foo.c.bar)).__next__()[0] + # Py2K avg_f = query.filter(foo.c.bar<30).values(sa.func.avg(foo.c.bar)).next()[0] + # end Py2K assert round(avg_f, 1) == 14.5 + # Py3K + #avg_o = query.filter(foo.c.bar<30).values(sa.func.avg(foo.c.bar)).__next__()[0] + # Py2K avg_o = query.filter(foo.c.bar<30).values(sa.func.avg(foo.c.bar)).next()[0] + # end Py2K assert round(avg_o, 1) == 14.5 @testing.resolve_artifact_names diff --git a/test/orm/inheritance/poly_linked_list.py b/test/orm/inheritance/poly_linked_list.py index 3fe9f9c8d2..73bc43ca32 100644 --- a/test/orm/inheritance/poly_linked_list.py +++ b/test/orm/inheritance/poly_linked_list.py @@ -69,7 +69,7 @@ class PolymorphicCircularTest(ORMTest): polymorphic_on=table1.c.type, polymorphic_identity='table1', properties={ - 'next': relation(Table1, + 'nxt': relation(Table1, backref=backref('prev', foreignkey=join.c.id, uselist=False), uselist=False, primaryjoin=join.c.id==join.c.related_id), 'data':relation(mapper(Data, data)) @@ -83,15 +83,16 @@ class PolymorphicCircularTest(ORMTest): # currently, the "eager" relationships degrade to lazy relationships # due to the polymorphic load. - # the "next" relation used to have a "lazy=False" on it, but the EagerLoader raises the "self-referential" + # the "nxt" relation used to have a "lazy=False" on it, but the EagerLoader raises the "self-referential" # exception now. since eager loading would never work for that relation anyway, its better that the user # gets an exception instead of it silently not eager loading. + # NOTE: using "nxt" instead of "next" to avoid 2to3 turning it into __next__() for some reason. table1_mapper = mapper(Table1, table1, #select_table=join, polymorphic_on=table1.c.type, polymorphic_identity='table1', properties={ - 'next': relation(Table1, + 'nxt': relation(Table1, backref=backref('prev', remote_side=table1.c.id, uselist=False), uselist=False, primaryjoin=table1.c.id==table1.c.related_id), 'data':relation(mapper(Data, data), lazy=False, order_by=data.c.id) @@ -144,7 +145,7 @@ class PolymorphicCircularTest(ORMTest): else: newobj = c if obj is not None: - obj.next = newobj + obj.nxt = newobj else: t = newobj obj = newobj @@ -158,7 +159,7 @@ class PolymorphicCircularTest(ORMTest): node = t while (node): assertlist.append(node) - n = node.next + n = node.nxt if n is not None: assert n.prev is node node = n @@ -171,7 +172,7 @@ class PolymorphicCircularTest(ORMTest): assertlist = [] while (node): assertlist.append(node) - n = node.next + n = node.nxt if n is not None: assert n.prev is node node = n @@ -185,7 +186,7 @@ class PolymorphicCircularTest(ORMTest): assertlist.insert(0, node) n = node.prev if n is not None: - assert n.next is node + assert n.nxt is node node = n backwards = repr(assertlist) -- 2.47.3