Skip to content

Commit 44637ed

Browse files
authored
tests, hook for exceptions only in debug mode (#643)
1 parent 480d125 commit 44637ed

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/_setup_test_env.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,14 @@ def _try_hook_into_tests():
9191
9292
Also see: https://youtrack.jetbrains.com/issue/PY-9848
9393
"""
94-
# get TestProgram instance from stack...
94+
# Check if this is run inside a debugger. Skip if this is not the case.
9595
import sys
96+
get_trace = getattr(sys, "gettrace", None)
97+
if not get_trace:
98+
return
99+
if get_trace() is None:
100+
return
101+
# get TestProgram instance from stack...
96102
from unittest import TestProgram
97103
from better_exchook import get_current_frame
98104
frame = get_current_frame()

0 commit comments

Comments
 (0)