From c722ad8d59567beee0053e8716ecedec8d5e861f Mon Sep 17 00:00:00 2001 From: aliowka Date: Wed, 17 Jun 2026 19:36:51 +0300 Subject: [PATCH] Support context-aware subprocess tracking in tests --- conftest.py | 6 ++++++ tests/sitecustomize.py | 10 ++++++++++ 2 files changed, 16 insertions(+) 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)