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

Function test_base_cmdloop_without_startup_commands

tests/test_cmd2.py:1030–1046  ·  view source on GitHub ↗
(monkeypatch)

Source from the content-addressed store, hash-verified

1028
1029
1030def test_base_cmdloop_without_startup_commands(monkeypatch) -> None:
1031 # Need to patch sys.argv so cmd2 doesn't think it was called with arguments equal to the py.test args
1032 testargs = ["prog"]
1033 with mock.patch.object(sys, "argv", testargs):
1034 app = create_outsim_app()
1035
1036 app.intro = "Hello World, this is an intro ..."
1037
1038 read_command_mock = mock.MagicMock(name="_read_command_line", return_value="quit")
1039 monkeypatch.setattr("cmd2.Cmd._read_command_line", read_command_mock)
1040
1041 expected = app.intro + "\n"
1042
1043 # Run the command loop
1044 app.cmdloop()
1045 out = app.stdout.getvalue()
1046 assert out == expected
1047
1048
1049def test_cmdfinalizations_runs(base_app, monkeypatch) -> None:

Callers

nothing calls this directly

Calls 3

create_outsim_appFunction · 0.85
cmdloopMethod · 0.80
getvalueMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…