@@ -303,6 +303,35 @@ def test_tool_line_handle():
303303 assert tool_line_handle .positions == positions
304304
305305
306+ @pytest .mark .parametrize ('direction' , ("horizontal" , "vertical" ))
307+ def test_span_selector_bound (direction ):
308+ fig , ax = plt .subplots (1 , 1 )
309+ ax .plot ([10 , 20 ], [10 , 30 ])
310+ ax .figure .canvas .draw ()
311+ x_bound = ax .get_xbound ()
312+ y_bound = ax .get_ybound ()
313+
314+ tool = widgets .SpanSelector (ax , print , direction , interactive = True )
315+ assert ax .get_xbound () == x_bound
316+ assert ax .get_ybound () == y_bound
317+
318+ bound = x_bound if direction == 'horizontal' else y_bound
319+ assert tool ._edge_handles .positions == list (bound )
320+
321+ press_data = [10.5 , 11.5 ]
322+ move_data = [11 , 13 ] # Updating selector is done in onmove
323+ release_data = move_data
324+ do_event (tool , 'press' , xdata = press_data [0 ], ydata = press_data [1 ], button = 1 )
325+ do_event (tool , 'onmove' , xdata = move_data [0 ], ydata = move_data [1 ], button = 1 )
326+
327+ assert ax .get_xbound () == x_bound
328+ assert ax .get_ybound () == y_bound
329+
330+ index = 0 if direction == 'horizontal' else 1
331+ handle_positions = [press_data [index ], release_data [index ]]
332+ assert tool ._edge_handles .positions == handle_positions
333+
334+
306335def check_lasso_selector (** kwargs ):
307336 ax = get_ax ()
308337
0 commit comments