(self, mock_exit)
| 422 | @trap |
| 423 | @patch("invoke.program.sys.exit") |
| 424 | def shows_UnexpectedExit_str_when_streams_hidden(self, mock_exit): |
| 425 | p = Program() |
| 426 | oops = UnexpectedExit( |
| 427 | Result( |
| 428 | command="meh", |
| 429 | exited=54, |
| 430 | stdout="things!", |
| 431 | stderr="ohnoz!", |
| 432 | encoding="utf-8", |
| 433 | hide=("stdout", "stderr"), |
| 434 | ) |
| 435 | ) |
| 436 | p.execute = Mock(side_effect=oops) |
| 437 | p.run("myapp foo") |
| 438 | # Expect repr() of exception prints to stderr |
| 439 | # NOTE: this partially duplicates a test in runners.py; whatever. |
| 440 | stderr = sys.stderr.getvalue() |
| 441 | expected = """Encountered a bad command exit code! |
| 442 | |
| 443 | Command: 'meh' |
| 444 | |
| 445 | Exit code: 54 |
| 446 | |
| 447 | Stdout: |
| 448 | |
| 449 | things! |
| 450 | |
| 451 | Stderr: |
| 452 | |
| 453 | ohnoz! |
| 454 | |
| 455 | """ |
| 456 | assert stderr == expected |
| 457 | # And exit with expected code (vs e.g. 1 or 0) |
| 458 | mock_exit.assert_called_with(54) |
| 459 | |
| 460 | @trap |
| 461 | @patch("invoke.program.sys.exit") |
nothing calls this directly
no test coverage detected