From 5fb56105ddd83b6394c49cd55af66ad1db554491 Mon Sep 17 00:00:00 2001 From: ankiaga <ankiaga@google.com> Date: Fri, 24 Nov 2023 11:04:00 +0530 Subject: [PATCH] Not using autouse fixtures for few tests where not needed --- tests/system/test_dbapi.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/system/test_dbapi.py b/tests/system/test_dbapi.py index 73356fb324..ada21fef2c 100644 --- a/tests/system/test_dbapi.py +++ b/tests/system/test_dbapi.py @@ -71,12 +71,14 @@ def dbapi_database(self, raw_database): raw_database.run_in_transaction(self.clear_table) @pytest.fixture(autouse=True) - def init_connection(self, shared_instance, dbapi_database): - self._conn = Connection(shared_instance, dbapi_database) - self._cursor = self._conn.cursor() + def init_connection(self, request, shared_instance, dbapi_database): + if "noautofixt" not in request.keywords: + self._conn = Connection(shared_instance, dbapi_database) + self._cursor = self._conn.cursor() yield - self._cursor.close() - self._conn.close() + if "noautofixt" not in request.keywords: + self._cursor.close() + self._conn.close() @pytest.fixture def execute_common_statements(self): @@ -199,6 +201,7 @@ def test_autocommit_mode_change(self): assert got_rows == [want_row] + @pytest.mark.noautofixt def test_rollback_on_connection_closing(self, shared_instance, dbapi_database): """ When closing a connection all the pending transactions @@ -303,6 +306,7 @@ def test_execute_many(self): assert res[0] == 1 + @pytest.mark.noautofixt def test_DDL_autocommit(self, shared_instance, dbapi_database): """Check that DDLs in autocommit mode are immediately executed.""" @@ -528,6 +532,7 @@ def test_json_array(self, dbapi_database): op = dbapi_database.update_ddl(["DROP TABLE JsonDetails"]) op.result() + @pytest.mark.noautofixt def test_DDL_commit(self, shared_instance, dbapi_database): """Check that DDLs in commit mode are executed on calling `commit()`.""" try: @@ -563,6 +568,7 @@ def test_ping(self): """Check connection validation method.""" self._conn.validate() + @pytest.mark.noautofixt def test_user_agent(self, shared_instance, dbapi_database): """Check that DB API uses an appropriate user agent.""" conn = connect(shared_instance.name, dbapi_database.name)