summaryrefslogtreecommitdiff
path: root/_pytest
diff options
context:
space:
mode:
authorAnthony Shaw <anthonyshaw@apache.org>2018-03-23 14:20:10 +1100
committerAnthony Shaw <anthonyshaw@apache.org>2018-03-23 14:20:10 +1100
commit21ada0fa23d20dcc2945ecb3f8ef5c62a96deac3 (patch)
tree7ed53ed37016ee72d31818777b6c91f931f51d14 /_pytest
parenta1ff758d0d0fbb1655e85472fe896b3356dac404 (diff)
downloadpytest-21ada0fa23d20dcc2945ecb3f8ef5c62a96deac3.tar.gz
add check for support of breakpoint() and use Custom Pdb class when system default is set
Diffstat (limited to '_pytest')
-rw-r--r--_pytest/debugging.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/_pytest/debugging.py b/_pytest/debugging.py
index bb21a9e0e..f73a9a6b9 100644
--- a/_pytest/debugging.py
+++ b/_pytest/debugging.py
@@ -2,6 +2,7 @@
from __future__ import absolute_import, division, print_function
import pdb
import sys
+import os
from doctest import UnexpectedException
try:
@@ -33,12 +34,19 @@ def pytest_configure(config):
if config.getvalue("usepdb"):
config.pluginmanager.register(PdbInvoke(), 'pdbinvoke')
+ # Use custom Pdb class set_trace instead of default Pdb on breakpoint() call
+ if SUPPORTS_BREAKPOINT_BUILTIN:
+ _environ_pythonbreakpoint = getattr(os.environ, 'PYTHONBREAKPOINT', '')
+ if _environ_pythonbreakpoint == '':
+ sys.breakpointhook = pytestPDB.set_trace
+
old = (pdb.set_trace, pytestPDB._pluginmanager)
def fin():
pdb.set_trace, pytestPDB._pluginmanager = old
pytestPDB._config = None
pytestPDB._pdb_cls = pdb.Pdb
+ sys.breakpointhook = sys.__breakpointhook__
pdb.set_trace = pytestPDB.set_trace
pytestPDB._pluginmanager = config.pluginmanager