(base_app: cmd2.Cmd)
| 4419 | |
| 4420 | |
| 4421 | def test_read_input_history_isolation(base_app: cmd2.Cmd) -> None: |
| 4422 | local_history = ["secret_command", "another_command"] |
| 4423 | |
| 4424 | # Mock _read_raw_input to prevent actual blocking |
| 4425 | # We want to inspect the session object passed to it |
| 4426 | with mock.patch.object(base_app, "_read_raw_input") as mock_raw: |
| 4427 | mock_raw.return_value = "user_input" |
| 4428 | |
| 4429 | base_app.read_input("prompt> ", history=local_history) |
| 4430 | |
| 4431 | # Inspect the session used in the call |
| 4432 | args, _ = mock_raw.call_args |
| 4433 | passed_session = args[1] |
| 4434 | |
| 4435 | # Verify the session's history contains our list |
| 4436 | loaded_history = list(passed_session.history.load_history_strings()) |
| 4437 | assert "secret_command" in loaded_history |
| 4438 | assert "another_command" in loaded_history |
| 4439 | |
| 4440 | # Verify the main app session was not touched |
| 4441 | # This is the crucial check for isolation |
| 4442 | main_history = base_app.main_session.history.get_strings() |
| 4443 | assert "secret_command" not in main_history |
| 4444 | |
| 4445 | |
| 4446 | @pytest.mark.skipif( |
nothing calls this directly
no test coverage detected
searching dependent graphs…