diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ddd0337..077e23f 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -31,6 +31,8 @@ jobs: MARIADB_DB: group_project MARIADB_USER: appuser MARIADB_PASSWORD: apppass + # Ensure the application uses MariaDB (async) during tests + DATABASE_URL: mysql+asyncmy://appuser:apppass@127.0.0.1:3306/group_project steps: - name: Check out repository code diff --git a/7project/backend/tests/conftest.py b/7project/backend/tests/conftest.py index 596aced..0f29b38 100644 --- a/7project/backend/tests/conftest.py +++ b/7project/backend/tests/conftest.py @@ -19,8 +19,9 @@ def fastapi_app(): return app -@pytest.fixture(scope="session") +@pytest.fixture(scope="function") def client(fastapi_app): + # Function-scoped to avoid leaking loop-bound resources into async tests return TestClient(fastapi_app, raise_server_exceptions=True)