| 1920 | |
| 1921 | |
| 1922 | def test_multiline_history_added(multiline_app, monkeypatch) -> None: |
| 1923 | # Test that multiline commands are added to history as a single item |
| 1924 | run_cmd(multiline_app, "history --clear") |
| 1925 | |
| 1926 | read_command_mock = mock.MagicMock(name="_read_command_line", side_effect=["person", "\n"]) |
| 1927 | monkeypatch.setattr("cmd2.Cmd._read_command_line", read_command_mock) |
| 1928 | |
| 1929 | # run_cmd calls onecmd_plus_hooks which triggers history addition |
| 1930 | run_cmd(multiline_app, "orate hi") |
| 1931 | |
| 1932 | assert len(multiline_app.history) == 1 |
| 1933 | assert multiline_app.history.get(1).raw == "orate hi\nperson\n\n" |
| 1934 | |
| 1935 | |
| 1936 | def test_multiline_history_with_quotes(multiline_app, monkeypatch) -> None: |