(capsys)
| 724 | |
| 725 | |
| 726 | def test_postcmd(capsys) -> None: |
| 727 | app = PluggedApp() |
| 728 | app.onecmd_plus_hooks("say hello") |
| 729 | out, err = capsys.readouterr() |
| 730 | assert out == "hello\n" |
| 731 | assert not err |
| 732 | # without registering any hooks, postcmd() should be called |
| 733 | assert app.called_postcmd == 1 |
| 734 | |
| 735 | app.reset_counters() |
| 736 | app.register_postcmd_hook(app.postcmd_hook) |
| 737 | app.onecmd_plus_hooks("say hello") |
| 738 | out, err = capsys.readouterr() |
| 739 | assert out == "hello\n" |
| 740 | assert not err |
| 741 | # with one hook registered, we should get precmd() and the hook |
| 742 | assert app.called_postcmd == 2 |
| 743 | |
| 744 | # register the function again, so it should be called twice |
| 745 | app.reset_counters() |
| 746 | app.register_postcmd_hook(app.postcmd_hook) |
| 747 | app.onecmd_plus_hooks("say hello") |
| 748 | out, err = capsys.readouterr() |
| 749 | assert out == "hello\n" |
| 750 | assert not err |
| 751 | # with two hooks registered, we should get precmd() and both hooks |
| 752 | assert app.called_postcmd == 3 |
| 753 | |
| 754 | |
| 755 | def test_postcmd_exception_first(capsys) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…