Skip to content

Commit 72301c7

Browse files
authored
Merge pull request #29147 from anntzer/pzt
Simplify synthetic event generation in interactive pan/zoom tests.
2 parents 647b005 + bc9b1ea commit 72301c7

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

lib/matplotlib/tests/test_backend_bases.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -540,18 +540,7 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis, forward_nav, t_s):
540540
ylim_b = init_ylim
541541

542542
tb.zoom()
543-
tb.press_zoom(start_event)
544-
tb.drag_zoom(drag_event)
545-
tb.release_zoom(stop_event)
546-
547-
assert ax_t.get_xlim() == pytest.approx(xlim_t, abs=0.15)
548-
assert ax_t.get_ylim() == pytest.approx(ylim_t, abs=0.15)
549-
assert ax_b.get_xlim() == pytest.approx(xlim_b, abs=0.15)
550-
assert ax_b.get_ylim() == pytest.approx(ylim_b, abs=0.15)
551543

552-
# Check if twin-axes are properly triggered
553-
assert ax_t.get_xlim() == pytest.approx(ax_t_twin.get_xlim(), abs=0.15)
554-
assert ax_b.get_xlim() == pytest.approx(ax_b_twin.get_xlim(), abs=0.15)
555544
else:
556545
# Evaluate expected limits
557546
# (call start_pan to make sure ax._pan_start is set)
@@ -576,15 +565,16 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis, forward_nav, t_s):
576565
ylim_b = init_ylim
577566

578567
tb.pan()
579-
tb.press_pan(start_event)
580-
tb.drag_pan(drag_event)
581-
tb.release_pan(stop_event)
582568

583-
assert ax_t.get_xlim() == pytest.approx(xlim_t, abs=0.15)
584-
assert ax_t.get_ylim() == pytest.approx(ylim_t, abs=0.15)
585-
assert ax_b.get_xlim() == pytest.approx(xlim_b, abs=0.15)
586-
assert ax_b.get_ylim() == pytest.approx(ylim_b, abs=0.15)
569+
start_event._process()
570+
drag_event._process()
571+
stop_event._process()
572+
573+
assert ax_t.get_xlim() == pytest.approx(xlim_t, abs=0.15)
574+
assert ax_t.get_ylim() == pytest.approx(ylim_t, abs=0.15)
575+
assert ax_b.get_xlim() == pytest.approx(xlim_b, abs=0.15)
576+
assert ax_b.get_ylim() == pytest.approx(ylim_b, abs=0.15)
587577

588-
# Check if twin-axes are properly triggered
589-
assert ax_t.get_xlim() == pytest.approx(ax_t_twin.get_xlim(), abs=0.15)
590-
assert ax_b.get_xlim() == pytest.approx(ax_b_twin.get_xlim(), abs=0.15)
578+
# Check if twin-axes are properly triggered
579+
assert ax_t.get_xlim() == pytest.approx(ax_t_twin.get_xlim(), abs=0.15)
580+
assert ax_b.get_xlim() == pytest.approx(ax_b_twin.get_xlim(), abs=0.15)

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,14 +2138,12 @@ def test_toolbar_zoom_pan(tool, button, key, expected):
21382138
tb = NavigationToolbar2(fig.canvas)
21392139
if tool == "zoom":
21402140
tb.zoom()
2141-
tb.press_zoom(start_event)
2142-
tb.drag_zoom(drag_event)
2143-
tb.release_zoom(stop_event)
21442141
else:
21452142
tb.pan()
2146-
tb.press_pan(start_event)
2147-
tb.drag_pan(drag_event)
2148-
tb.release_pan(stop_event)
2143+
2144+
start_event._process()
2145+
drag_event._process()
2146+
stop_event._process()
21492147

21502148
# Should be close, but won't be exact due to screen integer resolution
21512149
xlim, ylim, zlim = expected

0 commit comments

Comments
 (0)