(capsys)
| 316 | |
| 317 | |
| 318 | def test_preloop_hooks(capsys) -> None: |
| 319 | # Need to patch sys.argv so cmd2 doesn't think it was called with arguments equal to the py.test args |
| 320 | testargs = ["prog", "say hello", "quit"] |
| 321 | |
| 322 | with mock.patch.object(sys, "argv", testargs): |
| 323 | app = PluggedApp() |
| 324 | |
| 325 | app.register_preloop_hook(app.prepost_hook_one) |
| 326 | app.register_preloop_hook(app.prepost_hook_two) |
| 327 | app.cmdloop() |
| 328 | out, err = capsys.readouterr() |
| 329 | assert out == "one\ntwo\nhello\n" |
| 330 | assert not err |
| 331 | |
| 332 | |
| 333 | def test_register_postloop_hook_too_many_parameters() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…