discover chatmail.ini in tests from CWD and all parent dirs (tox runs change dirs)

This commit is contained in:
holger krekel
2023-12-11 02:27:05 +01:00
parent 0662e3a8b1
commit 0aa0ef8a74

View File

@@ -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