fix: isolate tests from real output/ dir via conftest autouse fixture

Tests imported the global job_queue (bound to real OUTPUT_DIR), creating
8 junk job-* dirs per pytest run (test_app x3, test_download_compress x4,
test_preview x1). Fixture redirects _output_dir to tmp_path and clears
the job registry before each test.
This commit is contained in:
jetson committed 2026-09-28 13:55:47 +07:00
1 parent f878110c3c
commit 9a276b21f2
1 file changed
+19
+19
View File
@@ -0,0 +1,19 @@
"""Global test isolation — keep tests out of the real output/ directory.
Tests import the global job_queue from app.py, which is bound to the real
OUTPUT_DIR. Without this, every pytest run leaves 8 junk job-* directories
in output/ (test_app × 3, test_download_compress × 4, test_preview × 1).
"""
import pytest
@pytest.fixture(autouse=True)
def _isolate_job_queue(tmp_path):
import app as app_module
q = app_module.job_queue
with q._lock:
q._output_dir = tmp_path / "output"
q._jobs.clear()
yield