(capsys)
| 780 | |
| 781 | |
| 782 | def test_postcmd_exception_second(capsys) -> None: |
| 783 | app = PluggedApp() |
| 784 | app.register_postcmd_hook(app.postcmd_hook) |
| 785 | stop = app.onecmd_plus_hooks("say hello") |
| 786 | out, err = capsys.readouterr() |
| 787 | assert not stop |
| 788 | assert out == "hello\n" |
| 789 | assert not err |
| 790 | # with one hook registered, we should get the hook and postcmd() |
| 791 | assert app.called_postcmd == 2 |
| 792 | |
| 793 | # register another function which should be called |
| 794 | app.reset_counters() |
| 795 | stop = app.register_postcmd_hook(app.postcmd_hook_exception) |
| 796 | app.onecmd_plus_hooks("say hello") |
| 797 | out, err = capsys.readouterr() |
| 798 | assert not stop |
| 799 | assert out == "hello\n" |
| 800 | assert err |
| 801 | # the exception raised by the first hook should prevent the second |
| 802 | # hook from being called, and it also prevents postcmd() from being |
| 803 | # called. So we have the first hook, and the second hook, which raised |
| 804 | # the exception |
| 805 | assert app.called_postcmd == 2 |
| 806 | |
| 807 | |
| 808 | ## |
nothing calls this directly
no test coverage detected
searching dependent graphs…