diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-01-06 10:43:19 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-01-15 13:04:58 -0500 |
commit | ebbbac0a76b3327a829864afb26ee1b7ff1dc780 (patch) | |
tree | b086b06760255bc0bb76e51624a5e3772bc4cc3d /lib/sqlalchemy/testing | |
parent | 6be06d85e598e4fda6f3d35084e1c5cccb30cee5 (diff) | |
download | sqlalchemy-ebbbac0a76b3327a829864afb26ee1b7ff1dc780.tar.gz |
update execute() arg formats in modules and tests
continuing with producing a SQLAlchemy 1.4.0b2 that internally
does not emit any of its own 2.0 deprecation warnings,
migrate the *args and **kwargs passed to execute() methods
that now must be a single list or dictionary.
Alembic 1.5 is again waiting on this internal consistency to
be present so that it can pass all tests with no 2.0
deprecation warnings.
Change-Id: If6b792e57c8c5dff205419644ab68e631575a2fa
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r-- | lib/sqlalchemy/testing/fixtures.py | 2 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/suite/test_insert.py | 24 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/suite/test_select.py | 8 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/suite/test_sequence.py | 8 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/suite/test_update_delete.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/warnings.py | 3 |
6 files changed, 27 insertions, 22 deletions
diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py index f19b4652a..dcdeee5c9 100644 --- a/lib/sqlalchemy/testing/fixtures.py +++ b/lib/sqlalchemy/testing/fixtures.py @@ -396,9 +396,7 @@ def stop_test_class_inside_fixtures(cls): def after_test(): - if _fixture_sessions: - _close_all_sessions() diff --git a/lib/sqlalchemy/testing/suite/test_insert.py b/lib/sqlalchemy/testing/suite/test_insert.py index da59d831f..35f3315c7 100644 --- a/lib/sqlalchemy/testing/suite/test_insert.py +++ b/lib/sqlalchemy/testing/suite/test_insert.py @@ -51,13 +51,15 @@ class LastrowidTest(fixtures.TablesTest): def test_autoincrement_on_insert(self, connection): - connection.execute(self.tables.autoinc_pk.insert(), data="some data") + connection.execute( + self.tables.autoinc_pk.insert(), dict(data="some data") + ) self._assert_round_trip(self.tables.autoinc_pk, connection) def test_last_inserted_id(self, connection): r = connection.execute( - self.tables.autoinc_pk.insert(), data="some data" + self.tables.autoinc_pk.insert(), dict(data="some data") ) pk = connection.scalar(select(self.tables.autoinc_pk.c.id)) eq_(r.inserted_primary_key, (pk,)) @@ -65,7 +67,7 @@ class LastrowidTest(fixtures.TablesTest): @requirements.dbapi_lastrowid def test_native_lastrowid_autoinc(self, connection): r = connection.execute( - self.tables.autoinc_pk.insert(), data="some data" + self.tables.autoinc_pk.insert(), dict(data="some data") ) lastrowid = r.lastrowid pk = connection.scalar(select(self.tables.autoinc_pk.c.id)) @@ -116,7 +118,9 @@ class InsertBehaviorTest(fixtures.TablesTest): engine = config.db with engine.begin() as conn: - r = conn.execute(self.tables.autoinc_pk.insert(), data="some data") + r = conn.execute( + self.tables.autoinc_pk.insert(), dict(data="some data") + ) assert r._soft_closed assert not r.closed assert r.is_insert @@ -131,7 +135,7 @@ class InsertBehaviorTest(fixtures.TablesTest): @requirements.returning def test_autoclose_on_insert_implicit_returning(self, connection): r = connection.execute( - self.tables.autoinc_pk.insert(), data="some data" + self.tables.autoinc_pk.insert(), dict(data="some data") ) assert r._soft_closed assert not r.closed @@ -315,7 +319,7 @@ class ReturningTest(fixtures.TablesTest): def test_explicit_returning_pk_autocommit(self, connection): table = self.tables.autoinc_pk r = connection.execute( - table.insert().returning(table.c.id), data="some data" + table.insert().returning(table.c.id), dict(data="some data") ) pk = r.first()[0] fetched_pk = connection.scalar(select(table.c.id)) @@ -324,7 +328,7 @@ class ReturningTest(fixtures.TablesTest): def test_explicit_returning_pk_no_autocommit(self, connection): table = self.tables.autoinc_pk r = connection.execute( - table.insert().returning(table.c.id), data="some data" + table.insert().returning(table.c.id), dict(data="some data") ) pk = r.first()[0] fetched_pk = connection.scalar(select(table.c.id)) @@ -332,13 +336,15 @@ class ReturningTest(fixtures.TablesTest): def test_autoincrement_on_insert_implicit_returning(self, connection): - connection.execute(self.tables.autoinc_pk.insert(), data="some data") + connection.execute( + self.tables.autoinc_pk.insert(), dict(data="some data") + ) self._assert_round_trip(self.tables.autoinc_pk, connection) def test_last_inserted_id_implicit_returning(self, connection): r = connection.execute( - self.tables.autoinc_pk.insert(), data="some data" + self.tables.autoinc_pk.insert(), dict(data="some data") ) pk = connection.scalar(select(self.tables.autoinc_pk.c.id)) eq_(r.inserted_primary_key, (pk,)) diff --git a/lib/sqlalchemy/testing/suite/test_select.py b/lib/sqlalchemy/testing/suite/test_select.py index f8d9b3d88..0d9f08848 100644 --- a/lib/sqlalchemy/testing/suite/test_select.py +++ b/lib/sqlalchemy/testing/suite/test_select.py @@ -742,7 +742,7 @@ class PostCompileParamsTest( with self.sql_execution_asserter() as asserter: with config.db.connect() as conn: - conn.execute(stmt, q=10) + conn.execute(stmt, dict(q=10)) asserter.assert_( CursorSQL( @@ -761,7 +761,7 @@ class PostCompileParamsTest( with self.sql_execution_asserter() as asserter: with config.db.connect() as conn: - conn.execute(stmt, q=[5, 6, 7]) + conn.execute(stmt, dict(q=[5, 6, 7])) asserter.assert_( CursorSQL( @@ -783,7 +783,7 @@ class PostCompileParamsTest( with self.sql_execution_asserter() as asserter: with config.db.connect() as conn: - conn.execute(stmt, q=[(5, 10), (12, 18)]) + conn.execute(stmt, dict(q=[(5, 10), (12, 18)])) asserter.assert_( CursorSQL( @@ -807,7 +807,7 @@ class PostCompileParamsTest( with self.sql_execution_asserter() as asserter: with config.db.connect() as conn: - conn.execute(stmt, q=[(5, "z1"), (12, "z3")]) + conn.execute(stmt, dict(q=[(5, "z1"), (12, "z3")])) asserter.assert_( CursorSQL( diff --git a/lib/sqlalchemy/testing/suite/test_sequence.py b/lib/sqlalchemy/testing/suite/test_sequence.py index d8c35ed0b..7445ade00 100644 --- a/lib/sqlalchemy/testing/suite/test_sequence.py +++ b/lib/sqlalchemy/testing/suite/test_sequence.py @@ -46,11 +46,13 @@ class SequenceTest(fixtures.TablesTest): ) def test_insert_roundtrip(self, connection): - connection.execute(self.tables.seq_pk.insert(), data="some data") + connection.execute(self.tables.seq_pk.insert(), dict(data="some data")) self._assert_round_trip(self.tables.seq_pk, connection) def test_insert_lastrowid(self, connection): - r = connection.execute(self.tables.seq_pk.insert(), data="some data") + r = connection.execute( + self.tables.seq_pk.insert(), dict(data="some data") + ) eq_( r.inserted_primary_key, (testing.db.dialect.default_sequence_base,) ) @@ -62,7 +64,7 @@ class SequenceTest(fixtures.TablesTest): @requirements.sequences_optional def test_optional_seq(self, connection): r = connection.execute( - self.tables.seq_opt_pk.insert(), data="some data" + self.tables.seq_opt_pk.insert(), dict(data="some data") ) eq_(r.inserted_primary_key, (1,)) diff --git a/lib/sqlalchemy/testing/suite/test_update_delete.py b/lib/sqlalchemy/testing/suite/test_update_delete.py index f7e6da98e..3fb51ead3 100644 --- a/lib/sqlalchemy/testing/suite/test_update_delete.py +++ b/lib/sqlalchemy/testing/suite/test_update_delete.py @@ -32,7 +32,9 @@ class SimpleUpdateDeleteTest(fixtures.TablesTest): def test_update(self, connection): t = self.tables.plain_pk - r = connection.execute(t.update().where(t.c.id == 2), data="d2_new") + r = connection.execute( + t.update().where(t.c.id == 2), dict(data="d2_new") + ) assert not r.is_insert assert not r.returns_rows diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py index 1b078a263..5699cd035 100644 --- a/lib/sqlalchemy/testing/warnings.py +++ b/lib/sqlalchemy/testing/warnings.py @@ -56,9 +56,6 @@ def setup_filters(): # Core execution # r"The (?:Executable|Engine)\.(?:execute|scalar)\(\) method", - r"The connection.execute\(\) method in SQLAlchemy 2.0 will accept " - "parameters as a single dictionary or a single sequence of " - "dictionaries only.", r"The Connection.connect\(\) method is considered legacy", # r".*DefaultGenerator.execute\(\)", # |