Skip to content

Commit 110eda1

Browse files
committed
pdb: handle quitting in post_mortem
`help quit` in pdb says: > Quit from the debugger. The program being executed is aborted. But pytest would continue with the next tests, often making it necessary to kill the pytest process when using `--pdb` and trying to cancel the tests using `KeyboardInterrupt` / `Ctrl-C`.
1 parent eabf15b commit 110eda1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/_pytest/debugging.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
""" interactive debugging with PDB, the Python Debugger. """
22
from __future__ import absolute_import, division, print_function
3+
4+
import os
35
import pdb
46
import sys
5-
import os
67
from doctest import UnexpectedException
78

9+
from _pytest import outcomes
810
from _pytest.config import hookimpl
911

1012
try:
@@ -164,8 +166,9 @@ def _enter_pdb(node, excinfo, rep):
164166
rep.toterminal(tw)
165167
tw.sep(">", "entering PDB")
166168
tb = _postmortem_traceback(excinfo)
167-
post_mortem(tb)
168169
rep._pdbshown = True
170+
if post_mortem(tb):
171+
outcomes.exit('Quitting debugger')
169172
return rep
170173

171174

@@ -196,3 +199,4 @@ def get_stack(self, f, t):
196199
p = Pdb()
197200
p.reset()
198201
p.interaction(None, t)
202+
return p.quitting

0 commit comments

Comments
 (0)