Skip to content

Commit

Permalink
Not using autouse fixtures for few tests where not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
ankiaga committed Nov 24, 2023
1 parent 75bf199 commit 5fb5610
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/system/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."""

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5fb5610

Please sign in to comment.