| 1787 | |
| 1788 | |
| 1789 | def test_select_uneven_tuples_labels(outsim_app, monkeypatch) -> None: |
| 1790 | # Test that uneven tuples still work and labels are handled correctly |
| 1791 | # Case 1: (value, label) - normal |
| 1792 | # Case 2: (value,) - label should be value |
| 1793 | # Case 3: (value, None) - label should be value |
| 1794 | options = [("v1", "l1"), ("v2",), ("v3", None)] |
| 1795 | |
| 1796 | # Mock read_input to return '1' |
| 1797 | read_input_mock = mock.MagicMock(name="read_input", return_value="1") |
| 1798 | monkeypatch.setattr("cmd2.Cmd.read_input", read_input_mock) |
| 1799 | |
| 1800 | result = outsim_app.select(options, "Choice? ") |
| 1801 | assert result == "v1" |
| 1802 | |
| 1803 | out = outsim_app.stdout.getvalue() |
| 1804 | assert "1. l1" in out |
| 1805 | assert "2. v2" in out |
| 1806 | assert "3. v3" in out |
| 1807 | |
| 1808 | |
| 1809 | def test_select_indexable_no_len(outsim_app, monkeypatch) -> None: |