Added state directory.

This commit is contained in:
2023-10-13 19:56:10 +02:00
parent 4ab4832d41
commit 740e5e2ebc
10 changed files with 74 additions and 35 deletions

View File

@@ -1,3 +1,4 @@
import os
import tempfile
from pathlib import Path
from typing import Iterator
@@ -7,5 +8,11 @@ import pytest
@pytest.fixture
def temporary_dir() -> Iterator[Path]:
with tempfile.TemporaryDirectory(prefix="pytest-") as dirpath:
yield Path(dirpath)
if os.getenv("TEST_KEEP_TEMPORARY_DIR"):
temp_dir = tempfile.mkdtemp(prefix="pytest-")
path = Path(temp_dir)
yield path
print("=========> Keeping temporary directory: ", path)
else:
with tempfile.TemporaryDirectory(prefix="pytest-") as dirpath:
yield Path(dirpath)