Skip to content

Commit 5bac379

Browse files
committed
tests: add a fixture for default_connection to avoid leakage across tests
1 parent 699100f commit 5bac379

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

tests/conftest.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,18 @@ def spark():
267267

268268

269269
@pytest.fixture(scope='function')
270-
def duckdb_cursor():
271-
connection = duckdb.connect('')
272-
yield connection
273-
connection.close()
270+
def duckdb_cursor(tmp_path):
271+
with duckdb.connect(tmp_path / "mytest") as connection:
272+
yield connection
273+
274+
275+
@pytest.fixture(scope='function')
276+
def default_con():
277+
# ensures each test uses a fresh default connection to avoid test leakage
278+
# threading_unsafe fixture
279+
duckdb.default_connection().close()
280+
with duckdb.default_connection() as conn:
281+
yield conn
274282

275283

276284
@pytest.fixture(scope='function')

0 commit comments

Comments
 (0)