add check for support of breakpoint() and use Custom Pdb class when system default is set
This commit is contained in:
parent
a1ff758d0d
commit
21ada0fa23
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
import pdb
|
import pdb
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
from doctest import UnexpectedException
|
from doctest import UnexpectedException
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -33,12 +34,19 @@ def pytest_configure(config):
|
||||||
if config.getvalue("usepdb"):
|
if config.getvalue("usepdb"):
|
||||||
config.pluginmanager.register(PdbInvoke(), 'pdbinvoke')
|
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)
|
old = (pdb.set_trace, pytestPDB._pluginmanager)
|
||||||
|
|
||||||
def fin():
|
def fin():
|
||||||
pdb.set_trace, pytestPDB._pluginmanager = old
|
pdb.set_trace, pytestPDB._pluginmanager = old
|
||||||
pytestPDB._config = None
|
pytestPDB._config = None
|
||||||
pytestPDB._pdb_cls = pdb.Pdb
|
pytestPDB._pdb_cls = pdb.Pdb
|
||||||
|
sys.breakpointhook = sys.__breakpointhook__
|
||||||
|
|
||||||
pdb.set_trace = pytestPDB.set_trace
|
pdb.set_trace = pytestPDB.set_trace
|
||||||
pytestPDB._pluginmanager = config.pluginmanager
|
pytestPDB._pluginmanager = config.pluginmanager
|
||||||
|
|
Loading…
Reference in New Issue