@@ -1690,46 +1690,23 @@ def test_polygon_selector_clear_method(ax):
1690
1690
onselect = mock .Mock (spec = noop , return_value = None )
1691
1691
tool = widgets .PolygonSelector (ax , onselect )
1692
1692
1693
- event_sequence = [
1694
- * polygon_place_vertex (50 , 50 ),
1695
- * polygon_place_vertex (150 , 50 ),
1696
- * polygon_place_vertex (50 , 150 ),
1697
- * polygon_place_vertex (50 , 50 ),
1698
- ]
1699
- expected_result = [(50 , 50 ), (150 , 50 ), (50 , 150 ), (50 , 50 )]
1700
-
1701
- for (etype , event_args ) in event_sequence :
1702
- do_event (tool , etype , ** event_args )
1703
-
1704
- artist = tool ._selection_artist
1705
-
1706
- assert tool ._selection_completed
1707
- assert tool .get_visible ()
1708
- assert artist .get_visible ()
1709
- np .testing .assert_equal (artist .get_xydata (), expected_result )
1710
- assert onselect .call_args == ((expected_result [:- 1 ],), {})
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 )
1711
1698
1712
- tool .clear ()
1713
- assert not tool ._selection_completed
1714
- np .testing .assert_equal (artist .get_xydata (), [(0 , 0 )])
1715
-
1716
- # Do another cycle of events to make sure we can
1717
- event_sequence = [
1718
- * polygon_place_vertex (50 , 50 ),
1719
- * polygon_place_vertex (100 , 50 ),
1720
- * polygon_place_vertex (50 , 150 ),
1721
- * polygon_place_vertex (50 , 50 ),
1722
- ]
1723
- expected_result2 = [(50 , 50 ), (100 , 50 ), (50 , 150 ), (50 , 50 )]
1699
+ artist = tool ._selection_artist
1724
1700
1725
- for (etype , event_args ) in event_sequence :
1726
- do_event (tool , etype , ** event_args )
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 ],), {})
1727
1706
1728
- assert tool ._selection_completed
1729
- assert tool .get_visible ()
1730
- assert artist .get_visible ()
1731
- np .testing .assert_equal (artist .get_xydata (), expected_result2 )
1732
- assert onselect .call_args == ((expected_result2 [:- 1 ],), {})
1707
+ tool .clear ()
1708
+ assert not tool ._selection_completed
1709
+ np .testing .assert_equal (artist .get_xydata (), [(0 , 0 )])
1733
1710
1734
1711
1735
1712
@pytest .mark .parametrize ("horizOn" , [False , True ])
0 commit comments