mirror of https://github.com/scrapy/scrapy.git
Support context-aware subprocess tracking in tests
This commit is contained in:
parent
086b1e4c31
commit
c722ad8d59
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue