diff options
Diffstat (limited to 'conftest.py')
-rw-r--r-- | conftest.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/conftest.py b/conftest.py index 65d13d5..e41a61d 100644 --- a/conftest.py +++ b/conftest.py @@ -9,6 +9,8 @@ from pathlib import Path import pytest import pkgutil +from tempfile import TemporaryDirectory +from typing import Iterable here = Path(__file__).resolve().parent sys.path.insert(0, str(here / 'src')) @@ -67,3 +69,12 @@ def no_gettext(monkeypatch, request): for module in modules_to_process: if hasattr(module, '_'): monkeypatch.setattr(module, '_', lambda message: message) + +@pytest.fixture +def tmpdir() -> Iterable[Path]: + """ + Provide test case with a temporary directory that will be automatically + deleted after the test. + """ + with TemporaryDirectory() as tmpdir: + yield Path(tmpdir) |