Skip to content

Commit 1b7597a

Browse files
committed
[4.6] tests: restore tracing function
Without this, `testing/test_pdb.py` (already without pexpect) will cause missing test coverage afterwards (for the same process).
1 parent 21680ff commit 1b7597a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

testing/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
# -*- coding: utf-8 -*-
2+
import sys
3+
24
import pytest
35

6+
if sys.gettrace():
7+
8+
@pytest.fixture(autouse=True)
9+
def restore_tracing():
10+
"""Restore tracing function (when run with Coverage.py).
11+
12+
https://bugs.python.org/issue37011
13+
"""
14+
orig_trace = sys.gettrace()
15+
yield
16+
if sys.gettrace() != orig_trace:
17+
sys.settrace(orig_trace)
18+
419

520
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
621
def pytest_collection_modifyitems(config, items):

0 commit comments

Comments
 (0)