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

Function test_postparsing_hook

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

Source from the content-addressed store, hash-verified

422
423
424def 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
450def test_postparsing_hook_stop_first(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…