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

Function test_multiline_complete_statement_eof

tests/test_cmd2.py:1957–1978  ·  view source on GitHub ↗
(multiline_app, monkeypatch)

Source from the content-addressed store, hash-verified

1955
1956
1957def test_multiline_complete_statement_eof(multiline_app, monkeypatch):
1958 # Mock poutput to verify it's called
1959 poutput_mock = mock.MagicMock(name="poutput")
1960 monkeypatch.setattr(multiline_app, "poutput", poutput_mock)
1961
1962 read_raw_mock = mock.MagicMock(name="_read_raw_input", side_effect=EOFError)
1963 monkeypatch.setattr("cmd2.Cmd._read_raw_input", read_raw_mock)
1964
1965 command = "orate"
1966 args = "hello world"
1967 line = f"{command} {args}"
1968
1969 # This should call _read_command_line, get 'eof', set nextline to '\n',
1970 # and then parse the line with the newline terminator.
1971 statement = multiline_app._complete_statement(line)
1972
1973 assert statement.command == command
1974 assert statement.args == args
1975 assert statement.terminator == "\n"
1976
1977 # Verify that poutput('\n') was called
1978 poutput_mock.assert_called_once_with("\n")
1979
1980
1981class CommandResultApp(cmd2.Cmd):

Callers

nothing calls this directly

Calls 1

_complete_statementMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…