diff options
| author | Gord Thompson <gord@gordthompson.com> | 2021-08-12 13:04:28 -0600 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-09-30 10:10:16 -0400 |
| commit | 257f9130c321aaa948690d0e49c7352ad1188abd (patch) | |
| tree | 2648c88460c3e5de847ee998edb7a6df0aa9b261 /test/dialect/postgresql | |
| parent | f7f2df607301afcd11dd49a2ccb632291de12d29 (diff) | |
| download | sqlalchemy-257f9130c321aaa948690d0e49c7352ad1188abd.tar.gz | |
Modernize tests - calling_mapper_directly
a few changes for py2k:
* map_imperatively() includes the check that a class
is being sent, this was only working for mapper() before
* the test suite didn't place the py2k "autouse" workaround
in the correct order, seemingly, tried to adjust the
per-test ordering setup in pytestplugin.py
Change-Id: I4cc39630724e810953cfda7b2afdadc8b948e3c2
Diffstat (limited to 'test/dialect/postgresql')
| -rw-r--r-- | test/dialect/postgresql/test_compiler.py | 9 | ||||
| -rw-r--r-- | test/dialect/postgresql/test_types.py | 8 |
2 files changed, 8 insertions, 9 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 0b56d8987..5ada6f592 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -41,7 +41,7 @@ from sqlalchemy.dialects.postgresql import TSRANGE from sqlalchemy.dialects.postgresql.base import PGDialect from sqlalchemy.dialects.postgresql.psycopg2 import PGDialect_psycopg2 from sqlalchemy.orm import aliased -from sqlalchemy.orm import mapper +from sqlalchemy.orm import clear_mappers from sqlalchemy.orm import Session from sqlalchemy.sql import column from sqlalchemy.sql import literal_column @@ -2728,7 +2728,7 @@ class InsertOnConflictTest(fixtures.TestBase, AssertsCompiledSQL): ) -class DistinctOnTest(fixtures.TestBase, AssertsCompiledSQL): +class DistinctOnTest(fixtures.MappedTest, AssertsCompiledSQL): """Test 'DISTINCT' with SQL expression language and orm.Query with an emphasis on PG's 'DISTINCT ON' syntax. @@ -2825,7 +2825,8 @@ class DistinctOnTest(fixtures.TestBase, AssertsCompiledSQL): class Foo(object): pass - mapper(Foo, self.table) + clear_mappers() + self.mapper_registry.map_imperatively(Foo, self.table) sess = Session() subq = sess.query(Foo).subquery() @@ -2842,7 +2843,7 @@ class DistinctOnTest(fixtures.TestBase, AssertsCompiledSQL): class Foo(object): pass - mapper(Foo, self.table) + self.mapper_registry.map_imperatively(Foo, self.table) a1 = aliased(Foo) sess = Session() self.assert_compile( diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index bb8e44876..92641fcc6 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -3034,17 +3034,15 @@ class HStoreRoundTripTest(fixtures.TablesTest): ) self._assert_data([{r"key \"foo\"": r'value \"bar"\ xyz'}], connection) - def test_orm_round_trip(self, connection): - from sqlalchemy import orm - + def test_orm_round_trip(self, registry): class Data(object): def __init__(self, name, data): self.name = name self.data = data - orm.mapper(Data, self.tables.data_table) + registry.map_imperatively(Data, self.tables.data_table) - with orm.Session(connection) as s: + with fixtures.fixture_session() as s: d = Data( name="r1", data={"key1": "value1", "key2": "value2", "key3": "value3"}, |
