From 257c238a88ede3194e46a7c0c210a7da08e0039d Mon Sep 17 00:00:00 2001 From: Debanjum Date: Fri, 6 Jun 2025 14:46:09 -0700 Subject: [PATCH] Improve DB clean up after test runs --- pytest.ini | 1 + tests/conftest.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/pytest.ini b/pytest.ini index 36d842ae..5446becc 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,5 +2,6 @@ DJANGO_SETTINGS_MODULE = khoj.app.settings pythonpath = . src testpaths = tests +addopts = --reuse-db --nomigrations markers = chatquality: marks tests as chatquality (deselect with '-m "not chatquality"') diff --git a/tests/conftest.py b/tests/conftest.py index e5ab3a8e..d1135c0c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -50,6 +50,13 @@ def enable_db_access_for_all_tests(db): pass +@pytest.fixture(scope="session", autouse=True) +def django_db_setup(django_db_setup, django_db_blocker): + """Ensure proper database setup and teardown for all tests.""" + with django_db_blocker.unblock(): + yield + + @pytest.fixture(scope="session") def search_config() -> SearchConfig: state.embeddings_model = dict()