From bea41936e665fc29ea0a09e8485cb659cf641e88 Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Thu, 25 Jun 2026 10:27:12 +0100 Subject: [PATCH] Always reset pytest working directory to invokation dir --- tests/conftest.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 992799666..2dc509a53 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,7 +4,6 @@ """ import os -import pathlib import traceback import warnings @@ -172,14 +171,13 @@ def reinitialise_error_module(): @pytest.fixture(autouse=True) # noqa: RUF076 -def return_to_root(): +def return_to_root(request): """Various parts of PROCESS change directories and do not always change back. This fixture ensures that, at the end of each test, the cwd is reset to what it was at the beginning of the test. """ - cwd = pathlib.Path.cwd() yield - os.chdir(cwd) + os.chdir(request.config.invocation_dir) @pytest.fixture(autouse=True) # noqa: RUF076