forked from andrew/feedmill-recounter
26 lines
956 B
Python
26 lines
956 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, monkeypatch):
|
||
# .env RECOUNTER_API_KEY must not leak into tests (it enables 401 auth);
|
||
# auth tests set/override it via their own monkeypatch.setenv calls.
|
||
monkeypatch.delenv("RECOUNTER_API_KEY", raising=False)
|
||
# Prevent host FCP zones.json auto-sync during isolated unit tests unless
|
||
# a test sets FCP_ZONES_PATH or passes fcp_zones_path explicitly.
|
||
monkeypatch.setenv("FCP_ZONES_PATH", "")
|
||
import app as app_module
|
||
|
||
q = app_module.job_queue
|
||
with q._lock:
|
||
q._output_dir = tmp_path / "output"
|
||
q._jobs.clear()
|
||
yield
|