diff --git a/tests/test_policy.py b/tests/test_policy.py index a2c22ea..fc22b80 100644 --- a/tests/test_policy.py +++ b/tests/test_policy.py @@ -1,4 +1,6 @@ +import shutil import tempfile +from collections.abc import Iterator from pathlib import Path import pytest @@ -15,13 +17,16 @@ from beaver_agent.policy import ( @pytest.fixture -def vault() -> Path: +def vault() -> Iterator[Path]: root = Path(tempfile.mkdtemp(prefix="beaver-vault-")) - for d in ("мета/бобер", "💬 чаты", "📅 дни", "👤 люди"): - (root / d).mkdir(parents=True) - (root / "💬 чаты/старый.md").write_text("x") - (root / "📅 дни/2026-08-29.md").write_text("x") - return root + try: + for d in ("мета/бобер", "💬 чаты", "📅 дни", "👤 люди"): + (root / d).mkdir(parents=True) + (root / "💬 чаты/старый.md").write_text("x") + (root / "📅 дни/2026-08-29.md").write_text("x") + yield root + finally: + shutil.rmtree(root, ignore_errors=True) @pytest.fixture