From 031f871709f19c6738dca37be8a04d6f58a871b7 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Aug 25 2021 14:05:30 +0000 Subject: Make tmp_path_cwd fixture generally available Signed-off-by: Nils Philippsen --- diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..214ccbe --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,12 @@ +import os + +import pytest + + +@pytest.fixture +def tmp_path_cwd(tmp_path): + """Return a temporary path and change into it""" + old_wd = os.getcwd() + os.chdir(tmp_path) + yield tmp_path + os.chdir(old_wd) diff --git a/tests/test_parse.py b/tests/test_parse.py index 21f9c39..fc1c86e 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -1,5 +1,4 @@ import tarfile -import os import sqlite3 from pathlib import Path from typing import Any, List, NamedTuple @@ -14,14 +13,6 @@ HERE = Path(__file__).parent TEST_DATA_DIR = HERE.parent / "test_data" -@pytest.fixture -def tmp_path_cwd(tmp_path): - old_wd = os.getcwd() - os.chdir(tmp_path) - yield tmp_path - os.chdir(old_wd) - - def _test_tarfile_factory(tarfile_path): """Wrap tarfile.open() context manager for fixtures