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

Function test_select_uneven_tuples_labels

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

Source from the content-addressed store, hash-verified

1787
1788
1789def 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
1809def test_select_indexable_no_len(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…