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

Function test_cmdfinalization_hook_exception

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

Source from the content-addressed store, hash-verified

892
893
894def test_cmdfinalization_hook_exception(capsys) -> None:
895 app = PluggedApp()
896 app.register_cmdfinalization_hook(app.cmdfinalization_hook_exception)
897 stop = app.onecmd_plus_hooks("say hello")
898 out, err = capsys.readouterr()
899 assert not stop
900 assert out == "hello\n"
901 assert err
902 assert app.called_cmdfinalization == 1
903
904 # register another function, but it shouldn't be called
905 app.reset_counters()
906 app.register_cmdfinalization_hook(app.cmdfinalization_hook)
907 stop = app.onecmd_plus_hooks("say hello")
908 out, err = capsys.readouterr()
909 assert not stop
910 assert out == "hello\n"
911 assert err
912 assert app.called_cmdfinalization == 1
913
914
915def test_cmdfinalization_hook_system_exit() -> 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…