generated from Luis/nextjs-python-web-template
19 lines
476 B
Python
19 lines
476 B
Python
import os
|
|
import tempfile
|
|
from pathlib import Path
|
|
from typing import Iterator
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def temporary_dir() -> Iterator[Path]:
|
|
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)
|