refactor template
This commit is contained in:
22
{{cookiecutter.project_slug}}/tests/conftest.py
Normal file
22
{{cookiecutter.project_slug}}/tests/conftest.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from {{ cookiecutter.package_name }}.config import clear_config_cache
|
||||
from {{ cookiecutter.package_name }}.config.paths import ENV_CONFIG_VAR
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _isolate_xdg_paths(monkeypatch, tmp_path_factory) -> None:
|
||||
temp_root = tmp_path_factory.mktemp("xdg")
|
||||
monkeypatch.setenv("XDG_CONFIG_HOME", str(temp_root / "config"))
|
||||
monkeypatch.setenv("XDG_DATA_HOME", str(temp_root / "data"))
|
||||
monkeypatch.delenv(ENV_CONFIG_VAR, raising=False)
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _clear_config_cache() -> None:
|
||||
clear_config_cache()
|
||||
yield
|
||||
clear_config_cache()
|
||||
Reference in New Issue
Block a user