(capsys)
| 624 | |
| 625 | |
| 626 | def test_precmd_hook_emptystatement_first(capsys) -> None: |
| 627 | app = PluggedApp() |
| 628 | app.register_precmd_hook(app.precmd_hook_emptystatement) |
| 629 | stop = app.onecmd_plus_hooks("say hello") |
| 630 | out, err = capsys.readouterr() |
| 631 | assert not stop |
| 632 | assert not out |
| 633 | assert not err |
| 634 | # since the registered hooks are called before precmd(), if a registered |
| 635 | # hook throws an exception, precmd() is never called |
| 636 | assert app.called_precmd == 1 |
| 637 | |
| 638 | # register another function but it shouldn't be called |
| 639 | app.reset_counters() |
| 640 | stop = app.register_precmd_hook(app.precmd_hook) |
| 641 | app.onecmd_plus_hooks("say hello") |
| 642 | out, err = capsys.readouterr() |
| 643 | assert not stop |
| 644 | assert not out |
| 645 | assert not err |
| 646 | # the exception raised by the first hook should prevent the second |
| 647 | # hook from being called, and it also prevents precmd() from being |
| 648 | # called |
| 649 | assert app.called_precmd == 1 |
| 650 | |
| 651 | |
| 652 | def test_precmd_hook_emptystatement_second(capsys) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…