Skip to content

Commit f7640d9

Browse files
Replace assert with match argument in the pytest.warns call
1 parent f8ba9d3 commit f7640d9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/matplotlib/tests/test_backend_bases.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ def test_toolbar_zoompan():
165165
plt.rcParams['toolbar'] = 'toolmanager'
166166
ax = plt.gca()
167167
assert ax.get_navigate_mode() is None
168-
with pytest.warns(UserWarning) as rec:
168+
expected_warning_regex = (r"The new Tool classes introduced in "
169+
r"v[0-9]*.[0-9]* are experimental")
170+
with pytest.warns(UserWarning, match=expected_warning_regex) as rec:
169171
ax.figure.canvas.manager.toolmanager.add_tool(name="zoom",
170172
tool=ToolZoom)
171173
ax.figure.canvas.manager.toolmanager.add_tool(name="pan",
@@ -178,7 +180,3 @@ def test_toolbar_zoompan():
178180
assert ax.get_navigate_mode() == "ZOOM"
179181
ax.figure.canvas.manager.toolmanager.trigger_tool('pan')
180182
assert ax.get_navigate_mode() == "PAN"
181-
assert(len(rec) == 4)
182-
for r in rec:
183-
assert("The new Tool classes introduced in v1.5 are experimental"
184-
in str(r.message))

0 commit comments

Comments
 (0)