diff --git a/src/documents/tests/conftest.py b/src/documents/tests/conftest.py index 7e75b9194..d1e93bf03 100644 --- a/src/documents/tests/conftest.py +++ b/src/documents/tests/conftest.py @@ -92,6 +92,23 @@ def sample_doc( ) +@pytest.fixture() +def _search_index(tmp_path: Path, settings: SettingsWrapper) -> None: + """Create a temp index directory and point INDEX_DIR at it. + + Resets the backend singleton before and after so each test gets a clean + index rather than reusing a stale singleton from another test. + """ + from documents.search import reset_backend + + index_dir = tmp_path / "index" + index_dir.mkdir() + settings.INDEX_DIR = index_dir + reset_backend() + yield + reset_backend() + + @pytest.fixture() def settings_timezone(settings: SettingsWrapper) -> zoneinfo.ZoneInfo: return zoneinfo.ZoneInfo(settings.TIME_ZONE) diff --git a/src/documents/tests/test_workflows.py b/src/documents/tests/test_workflows.py index 58d989882..0fd893a5b 100644 --- a/src/documents/tests/test_workflows.py +++ b/src/documents/tests/test_workflows.py @@ -4802,6 +4802,7 @@ class TestWebhookSecurity: @pytest.mark.django_db +@pytest.mark.usefixtures("_search_index") class TestDateWorkflowLocalization( SampleDirMixin, ):