Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6d339ed

Browse filesBrowse files
authored
Merge pull request #6761 from Kojoley/fix-warnings-catching
TST: Fixed warnings catching and counting with `warnings.catch_warnings`
2 parents 019d6a8 + 5491777 commit 6d339ed
Copy full SHA for 6d339ed

File tree

Expand file treeCollapse file tree

4 files changed

+21
-12
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+21
-12
lines changed

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,6 +2666,7 @@ def test_eventplot_problem_kwargs():
26662666
axobj = fig.add_subplot(111)
26672667

26682668
with warnings.catch_warnings(record=True) as w:
2669+
warnings.simplefilter("always")
26692670
colls = axobj.eventplot(data,
26702671
colors=['r', 'b'],
26712672
color=['c', 'm'],
@@ -4017,6 +4018,7 @@ def test_pathological_hexbin():
40174018
out = io.BytesIO()
40184019

40194020
with warnings.catch_warnings(record=True) as w:
4021+
warnings.simplefilter("always")
40204022
mylist = [10] * 100
40214023
fig, ax = plt.subplots(1, 1)
40224024
ax.hexbin(mylist, mylist)
@@ -4236,10 +4238,11 @@ def test_errorbar_inputs_shotgun():
42364238
def test_axisbg_warning():
42374239
fig = plt.figure()
42384240
with warnings.catch_warnings(record=True) as w:
4241+
warnings.simplefilter("always")
42394242
ax = matplotlib.axes.Axes(fig, [0, 0, 1, 1], axisbg='r')
4240-
assert len(w) == 1
4241-
assert (str(w[0].message).startswith(
4242-
("The axisbg attribute was deprecated in version 2.0.")))
4243+
assert len(w) == 1
4244+
msg = "The axisbg attribute was deprecated in version 2.0."
4245+
assert str(w[0].message).startswith(msg)
42434246

42444247

42454248
@image_comparison(baseline_images=["dash_offset"], remove_text=True)

‎lib/matplotlib/tests/test_contour.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_contour.py
+10-7Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,9 @@ def test_contourf_decreasing_levels():
288288
# Legacy contouring algorithm gives a warning rather than raising an error,
289289
# plus a DeprecationWarning.
290290
with warnings.catch_warnings(record=True) as w:
291+
warnings.simplefilter("always")
291292
plt.contourf(z, [1.0, 0.0], corner_mask='legacy')
292-
assert_equal(len(w), 2)
293+
assert_equal(len(w), 2)
293294

294295

295296
@cleanup
@@ -299,16 +300,18 @@ def test_vminvmax_warning():
299300
cs = plt.contourf(z, [0.0, 1.0])
300301

301302
with warnings.catch_warnings(record=True) as w:
303+
warnings.simplefilter("always")
302304
cs.vmin
303-
assert len(w) == 1
304-
assert (str(w[0].message).startswith(
305-
("vmin is deprecated and will be removed in 2.2 ")))
305+
assert len(w) == 1
306+
msg = "vmin is deprecated and will be removed in 2.2 "
307+
assert str(w[0].message).startswith(msg)
306308

307309
with warnings.catch_warnings(record=True) as w:
310+
warnings.simplefilter("always")
308311
cs.vmax
309-
assert len(w) == 1
310-
assert (str(w[0].message).startswith(
311-
("vmax is deprecated and will be removed in 2.2 ")))
312+
assert len(w) == 1
313+
msg = "vmax is deprecated and will be removed in 2.2 "
314+
assert str(w[0].message).startswith(msg)
312315

313316

314317
if __name__ == '__main__':

‎lib/matplotlib/tests/test_figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_figure.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from six.moves import xrange
66

77
from nose.tools import assert_equal, assert_true
8+
from matplotlib import rcParams
89
from matplotlib.testing.decorators import image_comparison, cleanup
910
from matplotlib.axes import Axes
1011
import matplotlib.pyplot as plt
@@ -124,9 +125,10 @@ def test_too_many_figures():
124125
import warnings
125126

126127
with warnings.catch_warnings(record=True) as w:
127-
for i in range(22):
128+
warnings.simplefilter("always")
129+
for i in range(rcParams['figure.max_open_warning'] + 1):
128130
fig = plt.figure()
129-
assert len(w) == 1
131+
assert len(w) == 1
130132

131133

132134
def test_iterability_axes_argument():

‎lib/matplotlib/tests/test_ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_ticker.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def test_NullLocator_set_params():
9797
"""
9898
loc = mticker.NullLocator()
9999
with warnings.catch_warnings(record=True) as w:
100+
warnings.simplefilter("always")
100101
loc.set_params()
101102
nose.tools.assert_equal(len(w), 1)
102103

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.