(outsim_app, monkeypatch)
| 1745 | |
| 1746 | |
| 1747 | def 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 | |
| 1767 | def test_select_choice_tty_ctrl_c(outsim_app, monkeypatch) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…