44from importlib .util import find_spec
55from pathlib import Path
66
7+ import matplotlib
78import pytest
89import yaml
10+ from packaging .version import Version
911
1012from yt .config import ytcfg
1113from yt .utilities .answer_testing .testing_utilities import (
1719 data_dir_load ,
1820)
1921
22+ MPL_VERSION = Version (matplotlib .__version__ )
23+
2024
2125def pytest_addoption (parser ):
2226 """
@@ -109,38 +113,31 @@ def pytest_configure(config):
109113 ):
110114 config .addinivalue_line ("filterwarnings" , value )
111115
112- # at the time of writing, astropy's wheels are behind numpy's latest
113- # version but this doesn't cause actual problems in our test suite, so
114- # we allow this warning to pass.
115- # last checked with astropy 4.2.1
116- config .addinivalue_line (
117- "filterwarnings" ,
118- (
119- "ignore:numpy.ndarray size changed, may indicate binary incompatibility. "
120- "Expected 80 from C header, got 88 from PyObject:RuntimeWarning"
121- ),
122- )
123- if find_spec ("astropy" ) is not None :
124- # astropy triggers this warning from itself, there's not much we can do on our side
125- # last checked with astropy 4.2.1
116+ if MPL_VERSION < Version ("3.0.0" ):
126117 config .addinivalue_line (
127- "filterwarnings" , "ignore::astropy.wcs.wcs.FITSFixedWarning"
118+ "filterwarnings" ,
119+ (
120+ "ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' "
121+ "is deprecated since Python 3.3,and in 3.9 it will stop working:DeprecationWarning"
122+ ),
128123 )
129124
130- if find_spec ("cartopy" ) is not None :
131- # cartopy still triggers this numpy warning
132- # last checked wtih cartopy 0.19.0
125+ if find_spec ("astropy" ) is not None :
126+ # at the time of writing, astropy's wheels are behind numpy's latest
127+ # version but this doesn't cause actual problems in our test suite
128+ # last updated with astropy 5.0 + numpy 1.22 + pytest 6.2.5
133129 config .addinivalue_line (
134130 "filterwarnings" ,
135131 (
136- "ignore:`np.float` is a deprecated alias for the builtin `float`. "
137- "To silence this warning, use `float` by itself. "
138- "Doing this will not modify any behavior and is safe. "
139- "If you specifically wanted the numpy scalar type, use `np.float64` here."
140- ":DeprecationWarning: "
132+ "ignore:numpy.ndarray size changed, may indicate binary incompatibility. Expected "
133+ r"(80 from C header, got 88|88 from C header, got 96|80 from C header, got 96)"
134+ " from PyObject:RuntimeWarning"
141135 ),
142136 )
143- # this warning *still* shows up on cartopy 0.19 so we'll ignore it
137+
138+ if find_spec ("cartopy" ) is not None :
139+ # This can be removed when cartopy 0.21 is released
140+ # see https://github.com/SciTools/cartopy/pull/1957
144141 config .addinivalue_line (
145142 "filterwarnings" ,
146143 (
@@ -158,6 +155,17 @@ def pytest_configure(config):
158155 ),
159156 )
160157
158+ if find_spec ("xarray" ) is not None :
159+ # this can be removed when upstream issue is closed and a fix published
160+ # https://github.com/pydata/xarray/issues/6092
161+ config .addinivalue_line (
162+ "filterwarnings" ,
163+ (
164+ "ignore:distutils Version classes are deprecated. "
165+ "Use packaging.version instead.:DeprecationWarning"
166+ ),
167+ )
168+
161169
162170def pytest_collection_modifyitems (config , items ):
163171 r"""
0 commit comments