tests: restore tracing function

Without this, `testing/test_pdb.py` (already without pexpect) will cause
missing test coverage afterwards (for the same process).
This commit is contained in:
Daniel Hahler 2019-06-05 11:21:44 +02:00
parent 5fdc2d7744
commit aab5687093
1 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,20 @@
import sys
import pytest
if sys.gettrace():
@pytest.fixture(autouse=True)
def restore_tracing():
"""Restore tracing function (when run with Coverage.py).
https://bugs.python.org/issue37011
"""
orig_trace = sys.gettrace()
yield
if sys.gettrace() != orig_trace:
sys.settrace(orig_trace)
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_collection_modifyitems(config, items):