@@ -226,6 +226,38 @@ def onselect(epress, erelease):
226226 assert tool .corners == ((100 , 112 , 100 , 88 ), (100 , 109 , 125 , 116 ))
227227
228228
229+ @pytest .mark .parametrize ('selector_class' , [widgets .RectangleSelector ,
230+ widgets .EllipseSelector ])
231+ def test_rotate_warning (selector_class ):
232+ # Check that a warning is raised when trying to rotate on a
233+ # non-equal aspect Axes.
234+ ax = get_ax ()
235+
236+ def onselect (epress , erelease ):
237+ pass
238+
239+ tool = selector_class (ax , onselect = onselect , interactive = True )
240+ ax .set_aspect (2 )
241+
242+ # Draw rectangle
243+ do_event (tool , 'press' , xdata = 100 , ydata = 100 )
244+ do_event (tool , 'onmove' , xdata = 130 , ydata = 140 )
245+ do_event (tool , 'release' , xdata = 130 , ydata = 140 )
246+ old_corners = tool .corners
247+
248+ # Try to rotate
249+ do_event (tool , 'on_key_press' , key = 'r' )
250+ do_event (tool , 'press' , xdata = 130 , ydata = 140 )
251+ # Check warning is raised
252+ with pytest .warns (UserWarning , match = 'Rotation is only implemented for '
253+ 'equal-aspect Axes.' ):
254+ do_event (tool , 'onmove' , xdata = 100 , ydata = 150 )
255+ do_event (tool , 'release' , xdata = 100 , ydata = 200 )
256+ do_event (tool , 'on_key_release' , key = 'r' )
257+ # Check that corners haven't moved
258+ assert tool .corners == old_corners
259+
260+
229261def check_span (* args , ** kwargs ):
230262 ax = get_ax ()
231263
0 commit comments