"""Fixtures every test gets. Both of them are about not touching the machine the tests run on. The cache: a lookup writes to ``~/.cache`` by default, and a test run that touches the real one leaves entries behind and reads back entries an earlier version wrote. Redirecting it per test makes each run start from nothing. The settings: locking a frequency out writes it into ``config.yaml``, and a test that reached the real one would silently change what the next real scan does. The constant is replaced in every module that holds a copy, so that forgetting to pass a directory somewhere cannot end in someone's own settings. """ import pytest import bandsaunter.browse import bandsaunter.cli import bandsaunter.config import bandsaunter.tui @pytest.fixture(autouse=True) def isolated_cache(tmp_path_factory, monkeypatch): monkeypatch.setenv("XDG_CACHE_HOME", str(tmp_path_factory.mktemp("cache"))) @pytest.fixture(autouse=True) def isolated_settings(tmp_path_factory, monkeypatch): where = tmp_path_factory.mktemp("config") for module in (bandsaunter.config, bandsaunter.browse, bandsaunter.cli, bandsaunter.tui): if hasattr(module, "DEFAULT_CONFIG_DIR"): monkeypatch.setattr(module, "DEFAULT_CONFIG_DIR", where) if hasattr(module, "DEFAULT_CONFIG_PATH"): monkeypatch.setattr(module, "DEFAULT_CONFIG_PATH", where / "config.yaml") monkeypatch.setenv("BANDSAUNTER_CONFIG_DIR", str(where)) return where