File tree Expand file tree Collapse file tree 4 files changed +11
-6
lines changed
Expand file tree Collapse file tree 4 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 33import io
44import os
55from pathlib import Path
6+ import warnings
67
78import numpy as np
89import pytest
@@ -84,6 +85,9 @@ def test_multipage_keep_empty(tmp_path):
8485 os .chdir (tmp_path )
8586
8687 # test empty pdf files
88+ # Due to order of `with` block execution, a warning for unclosed file is raised
89+ # but the pytest.warns must happen before the PdfPages is created
90+ warnings .filterwarnings ("ignore" , category = ResourceWarning )
8791
8892 # an empty pdf is left behind with keep_empty unset
8993 with pytest .warns (mpl .MatplotlibDeprecationWarning ), PdfPages ("a.pdf" ) as pdf :
Original file line number Diff line number Diff line change @@ -147,8 +147,7 @@ def test_double_register_builtin_cmap():
147147 with pytest .raises (ValueError , match = 'A colormap named "viridis"' ):
148148 with pytest .warns (mpl .MatplotlibDeprecationWarning ):
149149 cm .register_cmap (name , mpl .colormaps [name ])
150- with pytest .warns (UserWarning ):
151- # TODO is warning more than once!
150+ with pytest .warns (UserWarning ), pytest .warns (mpl .MatplotlibDeprecationWarning ):
152151 cm .register_cmap (name , mpl .colormaps [name ], override_builtin = True )
153152
154153
Original file line number Diff line number Diff line change @@ -106,14 +106,12 @@ def test_rcparams_update():
106106 rc = mpl .RcParams ({'figure.figsize' : (3.5 , 42 )})
107107 bad_dict = {'figure.figsize' : (3.5 , 42 , 1 )}
108108 # make sure validation happens on input
109- with pytest .raises (ValueError ), \
110- pytest .warns (UserWarning , match = "validate" ):
109+ with pytest .raises (ValueError ):
111110 rc .update (bad_dict )
112111
113112
114113def test_rcparams_init ():
115- with pytest .raises (ValueError ), \
116- pytest .warns (UserWarning , match = "validate" ):
114+ with pytest .raises (ValueError ):
117115 mpl .RcParams ({'figure.figsize' : (3.5 , 42 , 1 )})
118116
119117
Original file line number Diff line number Diff line change 33import locale
44import logging
55import re
6+ import warnings
67
78import numpy as np
89from numpy .testing import assert_almost_equal , assert_array_equal
@@ -914,6 +915,9 @@ def test_mathtext_ticks(self):
914915 'axes.formatter.use_mathtext' : False
915916 })
916917
918+ # Glyph warning unrelated
919+ warnings .filterwarnings ("ignore" , category = UserWarning , message = "Glyph 8722" )
920+
917921 with pytest .warns (UserWarning , match = 'cmr10 font should ideally' ):
918922 fig , ax = plt .subplots ()
919923 ax .set_xticks ([- 1 , 0 , 1 ])
You can’t perform that action at this time.
0 commit comments