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

Function test_preloop_hook

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

Source from the content-addressed store, hash-verified

302
303
304def test_preloop_hook(capsys) -> None:
305 # Need to patch sys.argv so cmd2 doesn't think it was called with arguments equal to the py.test args
306 testargs = ["prog", "say hello", "quit"]
307
308 with mock.patch.object(sys, "argv", testargs):
309 app = PluggedApp()
310
311 app.register_preloop_hook(app.prepost_hook_one)
312 app.cmdloop()
313 out, err = capsys.readouterr()
314 assert out == "one\nhello\n"
315 assert not err
316
317
318def test_preloop_hooks(capsys) -> 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…