Skip to content

Commit ddca0ed

Browse files
fix: Change connection_by_backend to function scope
Changed from session to function scope to ensure database.backend config is restored immediately after each multi-backend test, preventing config pollution that caused subsequent tests to run with the wrong backend.
1 parent cb0d544 commit ddca0ed

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,13 @@ def db_creds_by_backend(backend, mysql_container, postgres_container):
324324
}
325325

326326

327-
@pytest.fixture(scope="session")
327+
@pytest.fixture(scope="function")
328328
def connection_by_backend(db_creds_by_backend):
329-
"""Create connection for the specified backend."""
329+
"""Create connection for the specified backend.
330+
331+
This fixture is function-scoped to ensure database.backend config
332+
is restored after each test, preventing config pollution between tests.
333+
"""
330334
# Save original config to restore after tests
331335
original_backend = dj.config.get("database.backend", "mysql")
332336
original_host = dj.config.get("database.host")

0 commit comments

Comments
 (0)