From 5ff82fcacf80f38395edc4f83fdc42b9670d87fd Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Wed, 15 Nov 2023 09:41:06 -0800 Subject: Use monkeypatch.chdir instead of os.chdir --- tests/conftest.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 3eb99cd..6088029 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,7 +17,6 @@ """Define fixtures used across all tests in this folder.""" -from os import chdir from pathlib import Path import pytest @@ -37,14 +36,18 @@ TEST_FILE_BYTES = ( ) -@pytest.fixture(autouse=True, scope="session") -def _chdir_to_tmp_dir(tmp_path_factory: pytest.TempPathFactory) -> None: +@pytest.fixture(autouse=True) +def _chdir_to_tmp_dir( + tmp_path_factory: pytest.TempPathFactory, monkeypatch: pytest.MonkeyPatch +) -> None: """Change to the base temporary directory before running tests. :param tmp_path_factory: temporary path generator :type tmp_path_factory: pytest.TempPathFactory + :param tmp_path_factory: Pytest monkeypatch helper + :type tmp_path_factory: pytest.MonkeyPatch """ - chdir(tmp_path_factory.getbasetemp()) + monkeypatch.chdir(tmp_path_factory.getbasetemp()) @pytest.fixture(scope="session") -- cgit v1.2.3