File tree 4 files changed +23
-12
lines changed
4 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -2725,7 +2725,7 @@ def close(self):
2725
2725
_api .warn_deprecated ("3.8" , message = (
2726
2726
"Keeping empty pdf files is deprecated since %(since)s and support "
2727
2727
"will be removed %(removal)s." ))
2728
- PdfFile (self ._filename , metadata = self ._metadata ) # touch the file.
2728
+ PdfFile (self ._filename , metadata = self ._metadata ). close () # touch the file.
2729
2729
2730
2730
def infodict (self ):
2731
2731
"""
Original file line number Diff line number Diff line change 1
1
import copy
2
2
import itertools
3
3
import unittest .mock
4
+ from packaging .version import parse as parse_version
4
5
5
6
from io import BytesIO
6
7
import numpy as np
@@ -147,9 +148,13 @@ def test_double_register_builtin_cmap():
147
148
with pytest .raises (ValueError , match = 'A colormap named "viridis"' ):
148
149
with pytest .warns (mpl .MatplotlibDeprecationWarning ):
149
150
cm .register_cmap (name , mpl .colormaps [name ])
150
- with pytest .warns (UserWarning ):
151
- # TODO is warning more than once!
152
- cm .register_cmap (name , mpl .colormaps [name ], override_builtin = True )
151
+
152
+ if parse_version (pytest .__version__ ).major < 8 :
153
+ with pytest .warns (UserWarning ):
154
+ cm .register_cmap (name , mpl .colormaps [name ], override_builtin = True )
155
+ else :
156
+ with pytest .warns (UserWarning ), pytest .warns (mpl .MatplotlibDeprecationWarning ):
157
+ cm .register_cmap (name , mpl .colormaps [name ], override_builtin = True )
153
158
154
159
155
160
def test_unregister_builtin_cmap ():
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
+ from packaging .version import parse as parse_version
6
7
7
8
import numpy as np
8
9
from numpy .testing import assert_almost_equal , assert_array_equal
@@ -914,10 +915,17 @@ def test_mathtext_ticks(self):
914
915
'axes.formatter.use_mathtext' : False
915
916
})
916
917
917
- with pytest .warns (UserWarning , match = 'cmr10 font should ideally' ):
918
- fig , ax = plt .subplots ()
919
- ax .set_xticks ([- 1 , 0 , 1 ])
920
- fig .canvas .draw ()
918
+ if parse_version (pytest .__version__ ).major < 8 :
919
+ with pytest .warns (UserWarning , match = 'cmr10 font should ideally' ):
920
+ fig , ax = plt .subplots ()
921
+ ax .set_xticks ([- 1 , 0 , 1 ])
922
+ fig .canvas .draw ()
923
+ else :
924
+ with (pytest .warns (UserWarning , match = "Glyph 8722" ),
925
+ pytest .warns (UserWarning , match = 'cmr10 font should ideally' )):
926
+ fig , ax = plt .subplots ()
927
+ ax .set_xticks ([- 1 , 0 , 1 ])
928
+ fig .canvas .draw ()
921
929
922
930
def test_cmr10_substitutions (self , caplog ):
923
931
mpl .rcParams .update ({
You can’t perform that action at this time.
0 commit comments