Skip to content

Commit bd04959

Browse files
Fix test case to cover the code changes
1 parent 92f6a11 commit bd04959

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

lib/matplotlib/tests/test_backend_bases.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from matplotlib.backend_bases import (
44
FigureCanvasBase, LocationEvent, MouseButton, MouseEvent,
55
NavigationToolbar2, RendererBase)
6+
from matplotlib.backend_tools import (ToolZoom, ToolPan,
7+
ToolViewsPositions, _views_positions)
68
import matplotlib.pyplot as plt
79
import matplotlib.transforms as transforms
810
import matplotlib.path as path
@@ -163,8 +165,20 @@ def test_toolbar_zoompan():
163165
plt.rcParams['toolbar'] = 'toolmanager'
164166
ax = plt.gca()
165167
assert ax.get_navigate_mode() is None
166-
tb = NavigationToolbar2(ax.figure.canvas)
167-
tb.zoom()
168-
assert ax.get_navigate_mode() == "ZOOM"
169-
tb.pan()
170-
assert ax.get_navigate_mode() == "PAN"
168+
with pytest.warns(UserWarning) as rec:
169+
ax.figure.canvas.manager.toolmanager.add_tool(name="zoom",
170+
tool=ToolZoom)
171+
ax.figure.canvas.manager.toolmanager.add_tool(name="pan",
172+
tool=ToolPan)
173+
ax.figure.canvas.manager.toolmanager.add_tool(name=_views_positions,
174+
tool=ToolViewsPositions)
175+
ax.figure.canvas.manager.toolmanager.trigger_tool('zoom')
176+
assert ax.get_navigate_mode() == "ZOOM"
177+
ax.figure.canvas.manager.toolmanager.trigger_tool('pan')
178+
assert ax.get_navigate_mode() == "PAN"
179+
assert(len(rec) == 4)
180+
for r in rec[:-1]:
181+
assert("The new Tool classes introduced in v1.5 are experimental"
182+
in str(r.message))
183+
assert("ToolManager does not control tool rubberband"
184+
in str(rec[-1].message))

0 commit comments

Comments
 (0)