MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_CheckButtons

Function test_CheckButtons

lib/matplotlib/tests/test_widgets.py:1046–1066  ·  view source on GitHub ↗
(ax)

Source from the content-addressed store, hash-verified

1044
1045
1046def test_CheckButtons(ax):
1047 labels = ('a', 'b', 'c')
1048 check = widgets.CheckButtons(ax, labels, (True, False, True))
1049 assert check.get_status() == [True, False, True]
1050 check.set_active(0)
1051 assert check.get_status() == [False, False, True]
1052 assert check.get_checked_labels() == ['c']
1053 check.clear()
1054 assert check.get_status() == [False, False, False]
1055 assert check.get_checked_labels() == []
1056
1057 for invalid_index in [-1, len(labels), len(labels)+5]:
1058 with pytest.raises(ValueError):
1059 check.set_active(index=invalid_index)
1060
1061 for invalid_value in ['invalid', -1]:
1062 with pytest.raises(TypeError):
1063 check.set_active(1, state=invalid_value)
1064
1065 cid = check.on_clicked(lambda: None)
1066 check.disconnect(cid)
1067
1068
1069@pytest.mark.parametrize("toolbar", ["none", "toolbar2", "toolmanager"])

Callers

nothing calls this directly

Calls 6

get_statusMethod · 0.95
set_activeMethod · 0.95
get_checked_labelsMethod · 0.95
clearMethod · 0.95
on_clickedMethod · 0.45
disconnectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…