Skip to content

Commit

Permalink
more work on config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Oct 13, 2023
1 parent da03773 commit d5b005c
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
from wagstails import MondoData


def test_config_directory_basic(base_data_dir: Path):
@pytest.fixture(scope="function")
def config_teardown():
"""Make sure environment variables are unset after running `test_config_directory`"""
yield
for varname in ("XDG_DATA_DIRS", "XDG_DATA_HOME", "WAGSTAILS_DIR"):
if varname in os.environ:
del os.environ[varname]


def test_config_directory(base_data_dir: Path):
"""Basic tests of directory configuration that shouldn't affect non-temporary files."""
m = MondoData(base_data_dir)
assert m._data_dir == base_data_dir
Expand All @@ -35,8 +44,12 @@ def test_config_directory_basic(base_data_dir: Path):
@pytest.mark.skipif(
os.environ.get("WAGSTAILS_TEST_ENV", "").lower() != "true", reason="Not in CI"
)
def test_config_directory_advanced():
"""Test running from a totally clean environment (i.e. CI)"""
def test_default_directory_configs():
"""Test default directory in ~/.local/share
Since this could affects things outside of the immediate code repo, this test
should mainly run in CI, where we can guarantee a clean user environment.
"""
m = MondoData()
assert m._data_dir == Path.home() / ".local" / "share" / "wagstails" / "mondo"
assert m._data_dir.exists() and m._data_dir.is_dir()
Expand Down

0 comments on commit d5b005c

Please sign in to comment.