MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / test_postparsing_hook_emptystatement_second

Function test_postparsing_hook_emptystatement_second

tests/test_plugin.py:508–536  ·  view source on GitHub ↗
(capsys)

Source from the content-addressed store, hash-verified

506
507
508def test_postparsing_hook_emptystatement_second(capsys) -> None:
509 app = PluggedApp()
510 app.register_postparsing_hook(app.postparse_hook)
511 stop = app.onecmd_plus_hooks("say hello")
512 out, err = capsys.readouterr()
513 assert not stop
514 assert out == "hello\n"
515 assert not err
516 assert app.called_postparsing == 1
517
518 # register another function and make sure it gets called
519 app.reset_counters()
520 app.register_postparsing_hook(app.postparse_hook_emptystatement)
521 stop = app.onecmd_plus_hooks("say hello")
522 out, err = capsys.readouterr()
523 assert not stop
524 assert not out
525 assert not err
526 assert app.called_postparsing == 2
527
528 # register a third function which shouldn't be called
529 app.reset_counters()
530 app.register_postparsing_hook(app.postparse_hook)
531 stop = app.onecmd_plus_hooks("say hello")
532 out, err = capsys.readouterr()
533 assert not stop
534 assert not out
535 assert not err
536 assert app.called_postparsing == 2
537
538
539def test_postparsing_hook_exception(capsys) -> None:

Callers

nothing calls this directly

Calls 4

PluggedAppClass · 0.85
onecmd_plus_hooksMethod · 0.80
reset_countersMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…