From 613d3e14eaeff84c18663f63cba501ac4c5b7321 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 11 Dec 2023 02:27:05 +0100 Subject: [PATCH] discover chatmail.ini in tests from CWD and all parent dirs (tox runs change dirs) --- tests/conftest.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 74c8d9dd..4bef976d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -40,10 +40,16 @@ def pytest_runtest_setup(item): @pytest.fixture def chatmail_config(pytestconfig): - path = Path("chatmail.ini").resolve() - if path.exists(): - return read_config(path) - pytest.skip(f"no chatmail.ini file found in {path}") + current = basedir = Path() + while 1: + path = current.joinpath("chatmail.ini").resolve() + if path.exists(): + return read_config(path) + if current == current.parent: + break + current = current.parent + + pytest.skip(f"no chatmail.ini file found in {basedir} or parent dirs") @pytest.fixture