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.
20 lines
541 B
Python
20 lines
541 B
Python
"""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
|