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

Function test_select_choice_tty

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

Source from the content-addressed store, hash-verified

1745
1746
1747def test_select_choice_tty(outsim_app, monkeypatch) -> None:
1748 # Mock choice to return the first option
1749 choice_mock = mock.MagicMock(name="choice", return_value="sweet")
1750 monkeypatch.setattr("cmd2.cmd2.choice", choice_mock)
1751
1752 prompt = "Sauce? "
1753 options = ["sweet", "salty"]
1754
1755 with create_pipe_input() as pipe_input:
1756 outsim_app.main_session = PromptSession(
1757 input=pipe_input,
1758 output=DummyOutput(),
1759 )
1760
1761 result = outsim_app.select(options, prompt)
1762
1763 assert result == "sweet"
1764 choice_mock.assert_called_once_with(message=prompt, options=[("sweet", "sweet"), ("salty", "salty")])
1765
1766
1767def test_select_choice_tty_ctrl_c(outsim_app, monkeypatch) -> None:

Callers

nothing calls this directly

Calls 1

selectMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…