Improve quitting from pdb

Regarding tests: it merges ``test_pdb_interaction``,
``test_pdb_print_captured_stdout``, and
``test_pdb_print_captured_stderr`` into
``test_pdb_print_captured_stdout_and_stderr`` (clarity and performance,
especially since pexpect tests are slow).
This commit is contained in:
Daniel Hahler
2018-10-31 16:20:44 +01:00
parent 4947eb85c0
commit e69b1255d7
4 changed files with 85 additions and 62 deletions

View File

@@ -118,6 +118,10 @@ class pytestPDB(object):
do_c = do_cont = do_continue
def set_quit(self):
super(_PdbWrapper, self).set_quit()
outcomes.exit("Quitting debugger")
def setup(self, f, tb):
"""Suspend on setup().
@@ -210,8 +214,7 @@ def _enter_pdb(node, excinfo, rep):
tw.sep(">", "entering PDB")
tb = _postmortem_traceback(excinfo)
rep._pdbshown = True
if post_mortem(tb):
outcomes.exit("Quitting debugger")
post_mortem(tb)
return rep
@@ -242,4 +245,5 @@ def post_mortem(t):
p = Pdb()
p.reset()
p.interaction(None, t)
return p.quitting
if p.quitting:
outcomes.exit("Quitting debugger")

View File

@@ -49,13 +49,13 @@ class Failed(OutcomeException):
__module__ = "builtins"
class Exit(SystemExit):
class Exit(Exception):
""" raised for immediate program exits (no tracebacks/summaries)"""
def __init__(self, msg="unknown reason", returncode=None):
self.msg = msg
self.returncode = returncode
SystemExit.__init__(self, msg)
super(Exit, self).__init__(msg)
# exposed helper methods
@@ -63,7 +63,7 @@ class Exit(SystemExit):
def exit(msg, returncode=None):
"""
Exit testing process as if SystemExit was triggered.
Exit testing process.
:param str msg: message to display upon exit.
:param int returncode: return code to be used when exiting pytest.