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

Function test_preloop_hooks

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

Source from the content-addressed store, hash-verified

316
317
318def test_preloop_hooks(capsys) -> None:
319 # Need to patch sys.argv so cmd2 doesn't think it was called with arguments equal to the py.test args
320 testargs = ["prog", "say hello", "quit"]
321
322 with mock.patch.object(sys, "argv", testargs):
323 app = PluggedApp()
324
325 app.register_preloop_hook(app.prepost_hook_one)
326 app.register_preloop_hook(app.prepost_hook_two)
327 app.cmdloop()
328 out, err = capsys.readouterr()
329 assert out == "one\ntwo\nhello\n"
330 assert not err
331
332
333def test_register_postloop_hook_too_many_parameters() -> None:

Callers

nothing calls this directly

Calls 3

PluggedAppClass · 0.85
register_preloop_hookMethod · 0.80
cmdloopMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…