(capsys)
| 422 | |
| 423 | |
| 424 | def test_postparsing_hook(capsys) -> None: |
| 425 | app = PluggedApp() |
| 426 | app.onecmd_plus_hooks("say hello") |
| 427 | out, err = capsys.readouterr() |
| 428 | assert out == "hello\n" |
| 429 | assert not err |
| 430 | assert not app.called_postparsing |
| 431 | |
| 432 | app.reset_counters() |
| 433 | app.register_postparsing_hook(app.postparse_hook) |
| 434 | app.onecmd_plus_hooks("say hello") |
| 435 | out, err = capsys.readouterr() |
| 436 | assert out == "hello\n" |
| 437 | assert not err |
| 438 | assert app.called_postparsing == 1 |
| 439 | |
| 440 | # register the function again, so it should be called twice |
| 441 | app.reset_counters() |
| 442 | app.register_postparsing_hook(app.postparse_hook) |
| 443 | app.onecmd_plus_hooks("say hello") |
| 444 | out, err = capsys.readouterr() |
| 445 | assert out == "hello\n" |
| 446 | assert not err |
| 447 | assert app.called_postparsing == 2 |
| 448 | |
| 449 | |
| 450 | def test_postparsing_hook_stop_first(capsys) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…