diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-01-04 15:18:25 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-01-05 23:46:02 -0500 |
| commit | 6fccdf4a285d5332ef49f23dc18c3ce45501d78b (patch) | |
| tree | d276e13e8960f00dc088c40908e4991248cc8639 /test/engine | |
| parent | 640cd8a70f8a664b7834c5f74ec322fdea644043 (diff) | |
| download | sqlalchemy-6fccdf4a285d5332ef49f23dc18c3ce45501d78b.tar.gz | |
remove more bound metadata
in Iae6ab95938a7e92b6d42086aec534af27b5577d3 I missed
that the "bind" was being stuck onto the MetaData in
TablesTest, which led thousands of ORM tests to still use
bound metadata. Keep looking for bound metadata.
standardize all ORM tests on a single means of getting a
Session when the Session API isn't the thing we are directly
testing, using a new function fixture_session() that replaces
create_session() and uses modern defaults.
Change-Id: Iaf71206e9ee568151496d8bc213a069504bf65ef
Diffstat (limited to 'test/engine')
| -rw-r--r-- | test/engine/test_deprecations.py | 96 | ||||
| -rw-r--r-- | test/engine/test_pool.py | 2 |
2 files changed, 72 insertions, 26 deletions
diff --git a/test/engine/test_deprecations.py b/test/engine/test_deprecations.py index 286231614..a18cf756b 100644 --- a/test/engine/test_deprecations.py +++ b/test/engine/test_deprecations.py @@ -69,25 +69,31 @@ class ConnectionlessDeprecationTest(fixtures.TestBase): metadata = MetaData() Table("test_table", metadata, Column("foo", Integer)) for meth in [metadata.create_all, metadata.drop_all]: - assert_raises_message( - exc.UnboundExecutionError, - "MetaData object is not bound to an Engine or Connection.", - meth, - ) + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods that invoke SQL" + ): + assert_raises_message( + exc.UnboundExecutionError, + "MetaData object is not bound to an Engine or Connection.", + meth, + ) def test_bind_create_drop_err_table(self): metadata = MetaData() table = Table("test_table", metadata, Column("foo", Integer)) for meth in [table.create, table.drop]: - assert_raises_message( - exc.UnboundExecutionError, - ( - "Table object 'test_table' is not bound to an Engine or " - "Connection." - ), - meth, - ) + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods that invoke SQL" + ): + assert_raises_message( + exc.UnboundExecutionError, + ( + "Table object 'test_table' is not bound to an " + "Engine or Connection." + ), + meth, + ) def test_bind_create_drop_bound(self): @@ -106,16 +112,28 @@ class ConnectionlessDeprecationTest(fixtures.TestBase): table = Table("test_table", metadata, Column("foo", Integer)) metadata.bind = bind assert metadata.bind is table.bind is bind - metadata.create_all() + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods that invoke SQL" + ): + metadata.create_all() with testing.expect_deprecated( r"The Table.exists\(\) method is deprecated and will " "be removed in a future release." ): assert table.exists() - metadata.drop_all() - table.create() - table.drop() + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods that invoke SQL" + ): + metadata.drop_all() + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods that invoke SQL" + ): + table.create() + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods that invoke SQL" + ): + table.drop() with testing.expect_deprecated( r"The Table.exists\(\) method is deprecated and will " "be removed in a future release." @@ -135,15 +153,27 @@ class ConnectionlessDeprecationTest(fixtures.TestBase): metadata.bind = bind assert metadata.bind is table.bind is bind - metadata.create_all() + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods that invoke SQL" + ): + metadata.create_all() with testing.expect_deprecated( r"The Table.exists\(\) method is deprecated and will " "be removed in a future release." ): assert table.exists() - metadata.drop_all() - table.create() - table.drop() + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods that invoke SQL" + ): + metadata.drop_all() + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods that invoke SQL" + ): + table.create() + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods that invoke SQL" + ): + table.drop() with testing.expect_deprecated( r"The Table.exists\(\) method is deprecated and will " "be removed in a future release." @@ -166,11 +196,27 @@ class ConnectionlessDeprecationTest(fixtures.TestBase): "test_table", metadata, Column("foo", Integer) ) assert metadata.bind is table.bind is bind - metadata.create_all() + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods " + "that invoke SQL" + ): + metadata.create_all() is_true(inspect(bind).has_table(table.name)) - metadata.drop_all() - table.create() - table.drop() + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods " + "that invoke SQL" + ): + metadata.drop_all() + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods " + "that invoke SQL" + ): + table.create() + with testing.expect_deprecated_20( + "The ``bind`` argument for schema methods " + "that invoke SQL" + ): + table.drop() is_false(inspect(bind).has_table(table.name)) finally: if isinstance(bind, engine.Connection): diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py index 1a49cf4b9..550fedb8e 100644 --- a/test/engine/test_pool.py +++ b/test/engine/test_pool.py @@ -101,7 +101,7 @@ class PoolTest(PoolTestBase): def test_cursor_iterable(self): conn = testing.db.raw_connection() cursor = conn.cursor() - cursor.execute(str(select([1], bind=testing.db))) + cursor.execute(str(select(1).compile(testing.db))) expected = [(1,)] for row in cursor: eq_(row, expected.pop(0)) |
