MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_keyboard_interrupt

Method test_keyboard_interrupt

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

Source from the content-addressed store, hash-verified

253
254 @pytest.mark.parametrize("fulltrace", ("", "--fulltrace"))
255 def test_keyboard_interrupt(self, pytester: Pytester, fulltrace) -> None:
256 pytester.makepyfile(
257 """
258 def test_foobar():
259 assert 0
260 def test_spamegg():
261 import py; pytest.skip('skip me please!')
262 def test_interrupt_me():
263 raise KeyboardInterrupt # simulating the user
264 """
265 )
266
267 result = pytester.runpytest(fulltrace, no_reraise_ctrlc=True)
268 result.stdout.fnmatch_lines(
269 [
270 " def test_foobar():",
271 "> assert 0",
272 "E assert 0",
273 "*_keyboard_interrupt.py:6: KeyboardInterrupt*",
274 ]
275 )
276 if fulltrace:
277 result.stdout.fnmatch_lines(
278 ["*raise KeyboardInterrupt # simulating the user*"]
279 )
280 else:
281 result.stdout.fnmatch_lines(
282 ["(to show a full traceback on KeyboardInterrupt use --full-trace)"]
283 )
284 result.stdout.fnmatch_lines(["*KeyboardInterrupt*"])
285
286 def test_keyboard_in_sessionstart(self, pytester: Pytester) -> None:
287 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