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

Function test_select_choice_tty_ctrl_c

tests/test_cmd2.py:1767–1786  ·  view source on GitHub ↗
(outsim_app, monkeypatch)

Source from the content-addressed store, hash-verified

1765
1766
1767def test_select_choice_tty_ctrl_c(outsim_app, monkeypatch) -> None:
1768 # Mock choice to raise KeyboardInterrupt
1769 choice_mock = mock.MagicMock(name="choice", side_effect=KeyboardInterrupt)
1770 monkeypatch.setattr("cmd2.cmd2.choice", choice_mock)
1771
1772 prompt = "Sauce? "
1773 options = ["sweet", "salty"]
1774
1775 # Mock isatty to be True for both stdin and stdout
1776 with create_pipe_input() as pipe_input:
1777 outsim_app.main_session = PromptSession(
1778 input=pipe_input,
1779 output=DummyOutput(),
1780 )
1781
1782 with pytest.raises(KeyboardInterrupt):
1783 outsim_app.select(options, prompt)
1784
1785 out = outsim_app.stdout.getvalue()
1786 assert out.rstrip().endswith("^C")
1787
1788
1789def test_select_uneven_tuples_labels(outsim_app, monkeypatch) -> None:

Callers

nothing calls this directly

Calls 2

selectMethod · 0.80
getvalueMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…