(self, pytester: Pytester, fulltrace)
| 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( |
nothing calls this directly
no test coverage detected