diff --git a/conftest.py b/conftest.py index cf0568111..31d818f22 100644 --- a/conftest.py +++ b/conftest.py @@ -161,3 +161,9 @@ def pytest_runtest_setup(item): # Generate localhost certificate files, needed by some tests generate_keys() + + +@pytest.hookimpl(tryfirst=True) +def pytest_runtest_setup(item): + import os + os.environ["DELTA_TEST_NAME"] = item.nodeid diff --git a/tests/sitecustomize.py b/tests/sitecustomize.py index 25532bafc..39bee4381 100644 --- a/tests/sitecustomize.py +++ b/tests/sitecustomize.py @@ -1,2 +1,12 @@ +import os import coverage + +# Start coverage first as configured coverage.process_startup() + +# If started, set the context to the active test name +cov = coverage.Coverage.current() +if cov: + test_name = os.environ.get("DELTA_TEST_NAME") + if test_name: + cov.switch_context(test_name)