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