fix(tests): vault fixture removes its temp dir
This commit is contained in:
1 parent
58338f132a
commit
0475e09c81
1 file changed
+7
-2
@@ -1,4 +1,6 @@
|
|||||||
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from collections.abc import Iterator
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -15,13 +17,16 @@ from beaver_agent.policy import (
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def vault() -> Path:
|
def vault() -> Iterator[Path]:
|
||||||
root = Path(tempfile.mkdtemp(prefix="beaver-vault-"))
|
root = Path(tempfile.mkdtemp(prefix="beaver-vault-"))
|
||||||
|
try:
|
||||||
for d in ("мета/бобер", "💬 чаты", "📅 дни", "👤 люди"):
|
for d in ("мета/бобер", "💬 чаты", "📅 дни", "👤 люди"):
|
||||||
(root / d).mkdir(parents=True)
|
(root / d).mkdir(parents=True)
|
||||||
(root / "💬 чаты/старый.md").write_text("x")
|
(root / "💬 чаты/старый.md").write_text("x")
|
||||||
(root / "📅 дни/2026-08-29.md").write_text("x")
|
(root / "📅 дни/2026-08-29.md").write_text("x")
|
||||||
return root
|
yield root
|
||||||
|
finally:
|
||||||
|
shutil.rmtree(root, ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
Reference in new issue
Block a user