From: Tobias Pfeiffer Date: Mon, 21 Nov 2022 23:50:02 +0000 (+0900) Subject: use connection fixture X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=539dfcb372360911b69aed2a804698bb1a2220b1;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git use connection fixture --- diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py index da10220c33..d2c9106d79 100644 --- a/test/dialect/test_sqlite.py +++ b/test/dialect/test_sqlite.py @@ -2303,57 +2303,54 @@ class ConstraintReflectionTest(fixtures.TestBase): ], ) - def test_reflect_partial_indexes(self): - with testing.db.begin() as conn: - conn.exec_driver_sql( - "create table foo_with_partial_index (x integer, y integer)" - ) - conn.exec_driver_sql( - "create unique index ix_partial on " - "foo_with_partial_index (x) where y > 10" - ) - conn.exec_driver_sql( - "create unique index ix_no_partial on " - "foo_with_partial_index (x)" - ) - conn.exec_driver_sql( - "create unique index ix_partial2 on " - "foo_with_partial_index (x, y) where " - "y = 10 or abs(x) < 5" - ) + def test_reflect_partial_indexes(self, connection): + connection.exec_driver_sql( + "create table foo_with_partial_index (x integer, y integer)" + ) + connection.exec_driver_sql( + "create unique index ix_partial on " + "foo_with_partial_index (x) where y > 10" + ) + connection.exec_driver_sql( + "create unique index ix_no_partial on " + "foo_with_partial_index (x)" + ) + connection.exec_driver_sql( + "create unique index ix_partial2 on " + "foo_with_partial_index (x, y) where " + "y = 10 or abs(x) < 5" + ) - inspector = inspect(conn) - indexes = inspector.get_indexes("foo_with_partial_index") - eq_( - indexes, - [ - { - "unique": 1, - "name": "ix_no_partial", - "column_names": ["x"], - "dialect_options": {}, - }, - { - "unique": 1, - "name": "ix_partial", - "column_names": ["x"], - "dialect_options": {"sqlite_where": mock.ANY}, - }, - { - "unique": 1, - "name": "ix_partial2", - "column_names": ["x", "y"], - "dialect_options": {"sqlite_where": mock.ANY}, - }, - ], - ) - assert ( - indexes[1]["dialect_options"]["sqlite_where"].text == "y > 10" - ) - assert ( - indexes[2]["dialect_options"]["sqlite_where"].text - == "y = 10 or abs(x) < 5" - ) + inspector = inspect(connection) + indexes = inspector.get_indexes("foo_with_partial_index") + eq_( + indexes, + [ + { + "unique": 1, + "name": "ix_no_partial", + "column_names": ["x"], + "dialect_options": {}, + }, + { + "unique": 1, + "name": "ix_partial", + "column_names": ["x"], + "dialect_options": {"sqlite_where": mock.ANY}, + }, + { + "unique": 1, + "name": "ix_partial2", + "column_names": ["x", "y"], + "dialect_options": {"sqlite_where": mock.ANY}, + }, + ], + ) + assert indexes[1]["dialect_options"]["sqlite_where"].text == "y > 10" + assert ( + indexes[2]["dialect_options"]["sqlite_where"].text + == "y = 10 or abs(x) < 5" + ) def test_unique_constraint_named(self): inspector = inspect(testing.db)