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

Function test_read_input_history_isolation

tests/test_cmd2.py:4421–4443  ·  view source on GitHub ↗
(base_app: cmd2.Cmd)

Source from the content-addressed store, hash-verified

4419
4420
4421def 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(

Callers

nothing calls this directly

Calls 2

read_inputMethod · 0.80
load_history_stringsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…