File tree Expand file tree Collapse file tree 3 files changed +22
-11
lines changed
Expand file tree Collapse file tree 3 files changed +22
-11
lines changed 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
@@ -146,9 +147,13 @@ def test_double_register_builtin_cmap():
146147 with pytest .raises (ValueError , match = 'A colormap named "viridis"' ):
147148 with pytest .warns (mpl .MatplotlibDeprecationWarning ):
148149 cm .register_cmap (name , mpl .colormaps [name ])
149- with pytest .warns (UserWarning ):
150- # TODO is warning more than once!
151- cm .register_cmap (name , mpl .colormaps [name ], override_builtin = True )
150+
151+ if parse_version (pytest .__version__ ).major < 8 :
152+ with pytest .warns (UserWarning ):
153+ cm .register_cmap (name , mpl .colormaps [name ], override_builtin = True )
154+ else :
155+ with pytest .warns (UserWarning ), pytest .warns (mpl .MatplotlibDeprecationWarning ):
156+ cm .register_cmap (name , mpl .colormaps [name ], override_builtin = True )
152157
153158
154159def test_unregister_builtin_cmap ():
Original file line number Diff line number Diff line change @@ -107,14 +107,12 @@ def test_rcparams_update():
107107 rc = mpl .RcParams ({'figure.figsize' : (3.5 , 42 )})
108108 bad_dict = {'figure.figsize' : (3.5 , 42 , 1 )}
109109 # make sure validation happens on input
110- with pytest .raises (ValueError ), \
111- pytest .warns (UserWarning , match = "validate" ):
110+ with pytest .raises (ValueError ):
112111 rc .update (bad_dict )
113112
114113
115114def test_rcparams_init ():
116- with pytest .raises (ValueError ), \
117- pytest .warns (UserWarning , match = "validate" ):
115+ with pytest .raises (ValueError ):
118116 mpl .RcParams ({'figure.figsize' : (3.5 , 42 , 1 )})
119117
120118
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
@@ -730,10 +731,17 @@ def test_mathtext_ticks(self):
730731 'axes.formatter.use_mathtext' : False
731732 })
732733
733- with pytest .warns (UserWarning , match = 'cmr10 font should ideally' ):
734- fig , ax = plt .subplots ()
735- ax .set_xticks ([- 1 , 0 , 1 ])
736- fig .canvas .draw ()
734+ if parse_version (pytest .__version__ ).major < 8 :
735+ with pytest .warns (UserWarning , match = 'cmr10 font should ideally' ):
736+ fig , ax = plt .subplots ()
737+ ax .set_xticks ([- 1 , 0 , 1 ])
738+ fig .canvas .draw ()
739+ else :
740+ with (pytest .warns (UserWarning , match = "Glyph 8722" ),
741+ pytest .warns (UserWarning , match = 'cmr10 font should ideally' )):
742+ fig , ax = plt .subplots ()
743+ ax .set_xticks ([- 1 , 0 , 1 ])
744+ fig .canvas .draw ()
737745
738746 def test_cmr10_substitutions (self , caplog ):
739747 mpl .rcParams .update ({
You can’t perform that action at this time.
0 commit comments