MCPcopy Create free account
hub / github.com/python-cmd2/cmd2 / test_multiline_history_with_quotes

Function test_multiline_history_with_quotes

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

Source from the content-addressed store, hash-verified

1934
1935
1936def test_multiline_history_with_quotes(multiline_app, monkeypatch) -> None:
1937 # Test combined multiline command with quotes is added to history correctly
1938 run_cmd(multiline_app, "history --clear")
1939
1940 read_command_mock = mock.MagicMock(name="_read_command_line", side_effect=[" and spaces ", ' "', " in", "quotes.", ";"])
1941 monkeypatch.setattr("cmd2.Cmd._read_command_line", read_command_mock)
1942
1943 line = 'orate Look, "There are newlines'
1944 run_cmd(multiline_app, line)
1945
1946 assert len(multiline_app.history) == 1
1947 history_item = multiline_app.history.get(1)
1948 history_lines = history_item.raw.splitlines()
1949 assert history_lines[0] == 'orate Look, "There are newlines'
1950 assert history_lines[1] == " and spaces "
1951 assert history_lines[2] == ' "'
1952 assert history_lines[3] == " in"
1953 assert history_lines[4] == "quotes."
1954 assert history_lines[5] == ";"
1955
1956
1957def test_multiline_complete_statement_eof(multiline_app, monkeypatch):

Callers

nothing calls this directly

Calls 2

run_cmdFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…