diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index d1136e51852b..9a1485c0f022 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -2666,6 +2666,7 @@ def test_eventplot_problem_kwargs(): axobj = fig.add_subplot(111) with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") colls = axobj.eventplot(data, colors=['r', 'b'], color=['c', 'm'], @@ -4017,6 +4018,7 @@ def test_pathological_hexbin(): out = io.BytesIO() with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") mylist = [10] * 100 fig, ax = plt.subplots(1, 1) ax.hexbin(mylist, mylist) @@ -4236,10 +4238,11 @@ def test_errorbar_inputs_shotgun(): def test_axisbg_warning(): fig = plt.figure() with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") ax = matplotlib.axes.Axes(fig, [0, 0, 1, 1], axisbg='r') - assert len(w) == 1 - assert (str(w[0].message).startswith( - ("The axisbg attribute was deprecated in version 2.0."))) + assert len(w) == 1 + msg = "The axisbg attribute was deprecated in version 2.0." + assert str(w[0].message).startswith(msg) @image_comparison(baseline_images=["dash_offset"], remove_text=True) diff --git a/lib/matplotlib/tests/test_contour.py b/lib/matplotlib/tests/test_contour.py index 15ee1c3b2313..59cf6fed8377 100644 --- a/lib/matplotlib/tests/test_contour.py +++ b/lib/matplotlib/tests/test_contour.py @@ -288,8 +288,9 @@ def test_contourf_decreasing_levels(): # Legacy contouring algorithm gives a warning rather than raising an error, # plus a DeprecationWarning. with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") plt.contourf(z, [1.0, 0.0], corner_mask='legacy') - assert_equal(len(w), 2) + assert_equal(len(w), 2) @cleanup @@ -299,16 +300,18 @@ def test_vminvmax_warning(): cs = plt.contourf(z, [0.0, 1.0]) with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") cs.vmin - assert len(w) == 1 - assert (str(w[0].message).startswith( - ("vmin is deprecated and will be removed in 2.2 "))) + assert len(w) == 1 + msg = "vmin is deprecated and will be removed in 2.2 " + assert str(w[0].message).startswith(msg) with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") cs.vmax - assert len(w) == 1 - assert (str(w[0].message).startswith( - ("vmax is deprecated and will be removed in 2.2 "))) + assert len(w) == 1 + msg = "vmax is deprecated and will be removed in 2.2 " + assert str(w[0].message).startswith(msg) if __name__ == '__main__': diff --git a/lib/matplotlib/tests/test_figure.py b/lib/matplotlib/tests/test_figure.py index f6260a51907b..ba45f133961d 100644 --- a/lib/matplotlib/tests/test_figure.py +++ b/lib/matplotlib/tests/test_figure.py @@ -5,6 +5,7 @@ from six.moves import xrange from nose.tools import assert_equal, assert_true +from matplotlib import rcParams from matplotlib.testing.decorators import image_comparison, cleanup from matplotlib.axes import Axes import matplotlib.pyplot as plt @@ -124,9 +125,10 @@ def test_too_many_figures(): import warnings with warnings.catch_warnings(record=True) as w: - for i in range(22): + warnings.simplefilter("always") + for i in range(rcParams['figure.max_open_warning'] + 1): fig = plt.figure() - assert len(w) == 1 + assert len(w) == 1 def test_iterability_axes_argument(): diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index 5477d31ff679..59deeaef892a 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -97,6 +97,7 @@ def test_NullLocator_set_params(): """ loc = mticker.NullLocator() with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") loc.set_params() nose.tools.assert_equal(len(w), 1)