From 4a7d6cc805324765db91e65034fce463a79383ba Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 10 Sep 2012 16:47:22 -0400 Subject: [PATCH] - backport test fixes from 0.8 to support newer postgresql, psycopg2 versions --- test/engine/test_execute.py | 4 ++-- test/orm/inheritance/test_abc_polymorphic.py | 14 ++++++++------ test/orm/test_eager_relations.py | 7 ++++--- test/sql/test_query.py | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index 39d2b9a634..69b94f13d4 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -238,8 +238,8 @@ class ExecuteTest(fixtures.TestBase): def test_stmt_exception_pickleable_no_dbapi(self): self._test_stmt_exception_pickleable(Exception("hello world")) - @testing.fails_on("postgresql+psycopg2", - "Packages the cursor in the exception") + @testing.crashes("postgresql+psycopg2", + "Older versions dont support cursor pickling, newer ones do") @testing.fails_on("mysql+oursql", "Exception doesn't come back exactly the same from pickle") @testing.fails_on("oracle+cx_oracle", diff --git a/test/orm/inheritance/test_abc_polymorphic.py b/test/orm/inheritance/test_abc_polymorphic.py index 8d1b5fec08..746bf0f130 100644 --- a/test/orm/inheritance/test_abc_polymorphic.py +++ b/test/orm/inheritance/test_abc_polymorphic.py @@ -5,6 +5,7 @@ from sqlalchemy.orm import * from test.lib.util import function_named from test.lib import fixtures from test.orm import _fixtures +from test.lib.testing import eq_ from test.lib.schema import Table, Column class ABCTest(fixtures.MappedTest): @@ -55,7 +56,8 @@ class ABCTest(fixtures.MappedTest): #for obj in sess.query(A).all(): # print obj - assert [ + eq_( + [ A(adata='a1'), B(bdata='b1', adata='b1'), B(bdata='b2', adata='b2'), @@ -63,22 +65,22 @@ class ABCTest(fixtures.MappedTest): C(cdata='c1', bdata='c1', adata='c1'), C(cdata='c2', bdata='c2', adata='c2'), C(cdata='c2', bdata='c2', adata='c2'), - ] == sess.query(A).order_by(A.id).all() + ], sess.query(A).order_by(A.id).all()) - assert [ + eq_([ B(bdata='b1', adata='b1'), B(bdata='b2', adata='b2'), B(bdata='b3', adata='b3'), C(cdata='c1', bdata='c1', adata='c1'), C(cdata='c2', bdata='c2', adata='c2'), C(cdata='c2', bdata='c2', adata='c2'), - ] == sess.query(B).all() + ], sess.query(B).order_by(A.id).all()) - assert [ + eq_([ C(cdata='c1', bdata='c1', adata='c1'), C(cdata='c2', bdata='c2', adata='c2'), C(cdata='c2', bdata='c2', adata='c2'), - ] == sess.query(C).all() + ], sess.query(C).order_by(A.id).all()) test_roundtrip = function_named( test_roundtrip, 'test_%s' % fetchtype) diff --git a/test/orm/test_eager_relations.py b/test/orm/test_eager_relations.py index deb985f696..c9138040aa 100644 --- a/test/orm/test_eager_relations.py +++ b/test/orm/test_eager_relations.py @@ -210,8 +210,8 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): sess = create_session() for q in [ - sess.query(Address).filter(Address.id.in_([1, 4, 5])), - sess.query(Address).filter(Address.id.in_([1, 4, 5])).limit(3) + sess.query(Address).filter(Address.id.in_([1, 4, 5])).order_by(Address.id), + sess.query(Address).filter(Address.id.in_([1, 4, 5])).order_by(Address.id).limit(3) ]: sess.expunge_all() eq_(q.all(), @@ -268,7 +268,8 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): sa.orm.clear_mappers() mapper(User, users, properties={ - 'addresses':relationship(Address, lazy='joined')}) + 'addresses':relationship(Address, lazy='joined', + order_by=addresses.c.id)}) mapper(Address, addresses, properties={ 'user_id':deferred(addresses.c.user_id), 'dingalings':relationship(Dingaling, lazy='joined')}) diff --git a/test/sql/test_query.py b/test/sql/test_query.py index 0b696894cf..302586df7a 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -445,7 +445,7 @@ class QueryTest(fixtures.TestBase): ), [(3,)]), (select([users.c.user_id]).\ where( - users.c.user_name.contains('i % t', escape='\\') + users.c.user_name.contains('i % t', escape='&') ), [(5,)]), ): eq_(expr.execute().fetchall(), result) -- 2.47.2