File tree 3 files changed +22
-11
lines changed
3 files changed +22
-11
lines changed 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
@@ -146,9 +147,13 @@ def test_double_register_builtin_cmap():
146
147
with pytest .raises (ValueError , match = 'A colormap named "viridis"' ):
147
148
with pytest .warns (mpl .MatplotlibDeprecationWarning ):
148
149
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 )
152
157
153
158
154
159
def test_unregister_builtin_cmap ():
Original file line number Diff line number Diff line change @@ -107,14 +107,12 @@ def test_rcparams_update():
107
107
rc = mpl .RcParams ({'figure.figsize' : (3.5 , 42 )})
108
108
bad_dict = {'figure.figsize' : (3.5 , 42 , 1 )}
109
109
# make sure validation happens on input
110
- with pytest .raises (ValueError ), \
111
- pytest .warns (UserWarning , match = "validate" ):
110
+ with pytest .raises (ValueError ):
112
111
rc .update (bad_dict )
113
112
114
113
115
114
def test_rcparams_init ():
116
- with pytest .raises (ValueError ), \
117
- pytest .warns (UserWarning , match = "validate" ):
115
+ with pytest .raises (ValueError ):
118
116
mpl .RcParams ({'figure.figsize' : (3.5 , 42 , 1 )})
119
117
120
118
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
@@ -730,10 +731,17 @@ def test_mathtext_ticks(self):
730
731
'axes.formatter.use_mathtext' : False
731
732
})
732
733
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 ()
737
745
738
746
def test_cmr10_substitutions (self , caplog ):
739
747
mpl .rcParams .update ({
You can’t perform that action at this time.
0 commit comments