# Keep all transient test artifacts under test/ and remove them after each test.
from pathlib import Path
import tempfile

import pytest


@pytest.fixture
def artifact_dir():
    root = Path(__file__).parent / '.tmp'
    root.mkdir(exist_ok=True)
    with tempfile.TemporaryDirectory(dir=root) as directory:
        yield Path(directory)
    try:
        root.rmdir()
    except OSError:
        pass
