Keep the tests away from the real data.txt

Refs #27
Task: MIL-004#5
This commit is contained in:
2026-10-13 14:38:54 +08:00
parent 4ef3874bb1
commit ba0ae0e698
2 changed files with 28 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
"""Shared pytest configuration for the snake game tests."""
from pathlib import Path
import pytest
@pytest.fixture(autouse=True)
def isolated_working_directory(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""Run every test in an empty temporary working directory.
The high score file has a relative default path (`data.txt`). Without this
fixture, a test that uses the default would read and write the real file of
the repository or of the directory pytest was started from.
"""
monkeypatch.chdir(tmp_path)