Skip to content

Commit d950dde

Browse files
committed
test that keyboardinterrupt exits the debugger
1 parent d3d8aaa commit d950dde

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

testing/test_pdb.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import platform
44
import os
5+
import signal
56

67
import _pytest._code
78
from _pytest.debugging import SUPPORTS_BREAKPOINT_BUILTIN
@@ -122,6 +123,18 @@ def test_func():
122123
assert rep.failed
123124
assert len(pdblist) == 1
124125

126+
def test_KeyboardInterrupt_exits_pdb(self, testdir, pdblist):
127+
p1 = testdir.makepyfile("""
128+
def test_func():
129+
raise KeyboardInterrupt
130+
""")
131+
child = testdir.spawn_pytest("--pdb %s" % p1)
132+
child.expect("(Pdb)")
133+
child.kill(signal.SIGINT)
134+
child.expect("KeyboardInterrupt")
135+
child.expect("====== 1 failed")
136+
self.flush(child)
137+
125138
def test_pdb_interaction(self, testdir):
126139
p1 = testdir.makepyfile("""
127140
def test_1():

0 commit comments

Comments
 (0)