MCPcopy
hub / github.com/pytest-dev/pytest / test_keyboard_interrupt

Method test_keyboard_interrupt

testing/test_terminal.py:287–316  ·  view source on GitHub ↗
(self, pytester: Pytester, fulltrace)

Source from the content-addressed store, hash-verified

285
286 @pytest.mark.parametrize("fulltrace", ("", "--fulltrace"))
287 def test_keyboard_interrupt(self, pytester: Pytester, fulltrace) -> None:
288 pytester.makepyfile(
289 """
290 def test_foobar():
291 assert 0
292 def test_spamegg():
293 import py; pytest.skip('skip me please!')
294 def test_interrupt_me():
295 raise KeyboardInterrupt # simulating the user
296 """
297 )
298
299 result = pytester.runpytest(fulltrace, no_reraise_ctrlc=True)
300 result.stdout.fnmatch_lines(
301 [
302 " def test_foobar():",
303 "> assert 0",
304 "E assert 0",
305 "*_keyboard_interrupt.py:6: KeyboardInterrupt*",
306 ]
307 )
308 if fulltrace:
309 result.stdout.fnmatch_lines(
310 ["*raise KeyboardInterrupt # simulating the user*"]
311 )
312 else:
313 result.stdout.fnmatch_lines(
314 ["(to show a full traceback on KeyboardInterrupt use --full-trace)"]
315 )
316 result.stdout.fnmatch_lines(["*KeyboardInterrupt*"])
317
318 def test_keyboard_in_sessionstart(self, pytester: Pytester) -> None:
319 pytester.makeconftest(

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected