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

Function test_cmdfinalization

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

Source from the content-addressed store, hash-verified

843
844
845def test_cmdfinalization(capsys) -> None:
846 app = PluggedApp()
847 app.onecmd_plus_hooks("say hello")
848 out, err = capsys.readouterr()
849 assert out == "hello\n"
850 assert not err
851 assert app.called_cmdfinalization == 0
852
853 app.register_cmdfinalization_hook(app.cmdfinalization_hook)
854 app.onecmd_plus_hooks("say hello")
855 out, err = capsys.readouterr()
856 assert out == "hello\n"
857 assert not err
858 assert app.called_cmdfinalization == 1
859
860 # register the function again, so it should be called twice
861 app.reset_counters()
862 app.register_cmdfinalization_hook(app.cmdfinalization_hook)
863 app.onecmd_plus_hooks("say hello")
864 out, err = capsys.readouterr()
865 assert out == "hello\n"
866 assert not err
867 assert app.called_cmdfinalization == 2
868
869
870def test_cmdfinalization_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…