diff --git a/testing/conftest.py b/testing/conftest.py index 6e01d710d..627ee763d 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -1,6 +1,21 @@ # -*- coding: utf-8 -*- +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):