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 3
3
import io
4
4
import os
5
5
from pathlib import Path
6
+ import warnings
6
7
7
8
import numpy as np
8
9
import pytest
@@ -84,6 +85,9 @@ def test_multipage_keep_empty(tmp_path):
84
85
os .chdir (tmp_path )
85
86
86
87
# 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 )
87
91
88
92
# an empty pdf is left behind with keep_empty unset
89
93
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():
147
147
with pytest .raises (ValueError , match = 'A colormap named "viridis"' ):
148
148
with pytest .warns (mpl .MatplotlibDeprecationWarning ):
149
149
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 ):
152
151
cm .register_cmap (name , mpl .colormaps [name ], override_builtin = True )
153
152
154
153
Original file line number Diff line number Diff line change @@ -106,14 +106,12 @@ def test_rcparams_update():
106
106
rc = mpl .RcParams ({'figure.figsize' : (3.5 , 42 )})
107
107
bad_dict = {'figure.figsize' : (3.5 , 42 , 1 )}
108
108
# make sure validation happens on input
109
- with pytest .raises (ValueError ), \
110
- pytest .warns (UserWarning , match = "validate" ):
109
+ with pytest .raises (ValueError ):
111
110
rc .update (bad_dict )
112
111
113
112
114
113
def test_rcparams_init ():
115
- with pytest .raises (ValueError ), \
116
- pytest .warns (UserWarning , match = "validate" ):
114
+ with pytest .raises (ValueError ):
117
115
mpl .RcParams ({'figure.figsize' : (3.5 , 42 , 1 )})
118
116
119
117
Original file line number Diff line number Diff line change 3
3
import locale
4
4
import logging
5
5
import re
6
+ import warnings
6
7
7
8
import numpy as np
8
9
from numpy .testing import assert_almost_equal , assert_array_equal
@@ -914,6 +915,9 @@ def test_mathtext_ticks(self):
914
915
'axes.formatter.use_mathtext' : False
915
916
})
916
917
918
+ # Glyph warning unrelated
919
+ warnings .filterwarnings ("ignore" , category = UserWarning , message = "Glyph 8722" )
920
+
917
921
with pytest .warns (UserWarning , match = 'cmr10 font should ideally' ):
918
922
fig , ax = plt .subplots ()
919
923
ax .set_xticks ([- 1 , 0 , 1 ])
You can’t perform that action at this time.
0 commit comments