| 390 | @trap |
| 391 | @patch("invoke.program.sys.exit") |
| 392 | def ParseErrors_display_message_and_exit_1(self, mock_exit): |
| 393 | p = Program() |
| 394 | # Run with a definitely-parser-angering incorrect input; the fact |
| 395 | # that this line doesn't raise an exception and thus fail the |
| 396 | # test, is what we're testing... |
| 397 | nah = "nopenotvalidsorry" |
| 398 | p.run("myapp {}".format(nah)) |
| 399 | # Expect that we did print the core body of the ParseError (e.g. |
| 400 | # "no idea what foo is!") and exit 1. (Intent is to display that |
| 401 | # info w/o a full traceback, basically.) |
| 402 | stderr = sys.stderr.getvalue() |
| 403 | assert stderr == "No idea what '{}' is!\n".format(nah) |
| 404 | mock_exit.assert_called_with(1) |
| 405 | |
| 406 | @trap |
| 407 | @patch("invoke.program.sys.exit") |