[4.6] tests: restore tracing function (#5408)

[4.6] tests: restore tracing function
This commit is contained in:
Bruno Oliveira 2019-06-05 20:01:55 -03:00 committed by GitHub
commit 1cae76b0fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -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):