File tree Expand file tree Collapse file tree 4 files changed +23
-12
lines changed
Expand file tree Collapse file tree 4 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -2732,7 +2732,7 @@ def close(self):
27322732 _api .warn_deprecated ("3.8" , message = (
27332733 "Keeping empty pdf files is deprecated since %(since)s and support "
27342734 "will be removed %(removal)s." ))
2735- PdfFile (self ._filename , metadata = self ._metadata ) # touch the file.
2735+ PdfFile (self ._filename , metadata = self ._metadata ). close () # touch the file.
27362736
27372737 def infodict (self ):
27382738 """
Original file line number Diff line number Diff line change 11import copy
22import itertools
33import unittest .mock
4+ from packaging .version import parse as parse_version
45
56from io import BytesIO
67import numpy as np
@@ -147,9 +148,13 @@ def test_double_register_builtin_cmap():
147148 with pytest .raises (ValueError , match = 'A colormap named "viridis"' ):
148149 with pytest .warns (mpl .MatplotlibDeprecationWarning ):
149150 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 )
153158
154159
155160def test_unregister_builtin_cmap ():
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+ from packaging .version import parse as parse_version
67
78import numpy as np
89from numpy .testing import assert_almost_equal , assert_array_equal
@@ -914,10 +915,17 @@ def test_mathtext_ticks(self):
914915 'axes.formatter.use_mathtext' : False
915916 })
916917
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 ()
921929
922930 def test_cmr10_substitutions (self , caplog ):
923931 mpl .rcParams .update ({
You can’t perform that action at this time.
0 commit comments