Files
feedmill-recounter/tests/conftest.py
T

26 lines
956 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""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