diff --git a/testing/conftest.py b/testing/conftest.py index 35d5f9661..635e7a614 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -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):