@@ -1686,6 +1686,29 @@ def test_polygon_selector_box(ax):
16861686 tool ._box .extents , (20.0 , 40.0 , 30.0 , 40.0 ))
16871687
16881688
1689+ def test_polygon_selector_clear_method (ax ):
1690+ onselect = mock .Mock (spec = noop , return_value = None )
1691+ tool = widgets .PolygonSelector (ax , onselect )
1692+
1693+ for result in ([(50 , 50 ), (150 , 50 ), (50 , 150 ), (50 , 50 )],
1694+ [(50 , 50 ), (100 , 50 ), (50 , 150 ), (50 , 50 )]):
1695+ for x , y in result :
1696+ for etype , event_args in polygon_place_vertex (x , y ):
1697+ do_event (tool , etype , ** event_args )
1698+
1699+ artist = tool ._selection_artist
1700+
1701+ assert tool ._selection_completed
1702+ assert tool .get_visible ()
1703+ assert artist .get_visible ()
1704+ np .testing .assert_equal (artist .get_xydata (), result )
1705+ assert onselect .call_args == ((result [:- 1 ],), {})
1706+
1707+ tool .clear ()
1708+ assert not tool ._selection_completed
1709+ np .testing .assert_equal (artist .get_xydata (), [(0 , 0 )])
1710+
1711+
16891712@pytest .mark .parametrize ("horizOn" , [False , True ])
16901713@pytest .mark .parametrize ("vertOn" , [False , True ])
16911714def test_MultiCursor (horizOn , vertOn ):
0 commit comments