Skip to content

Commit b6f71c8

Browse files
committed
Make the array API submodule not break the test suite
The warning is issued on import, which otherwise breaks pytest collection. If we manually import early and ignore the warning, any further imports of the module won't issue the warning again, due to the way Python caches imports.
1 parent fcdadee commit b6f71c8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

numpy/_pytesttester.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,20 @@ def __call__(self, label='fast', verbose=1, extra_argv=None,
137137
# offset verbosity. The "-q" cancels a "-v".
138138
pytest_args += ["-q"]
139139

140-
# Filter out distutils cpu warnings (could be localized to
141-
# distutils tests). ASV has problems with top level import,
142-
# so fetch module for suppression here.
143140
with warnings.catch_warnings():
144141
warnings.simplefilter("always")
142+
# Filter out distutils cpu warnings (could be localized to
143+
# distutils tests). ASV has problems with top level import,
144+
# so fetch module for suppression here.
145145
from numpy.distutils import cpuinfo
146146

147+
# Ignore the warning from importing the array_api submodule. This
148+
# warning is done on import, so it would break pytest collection,
149+
# but importing it early here prevents the warning from being
150+
# issued when it imported again.
151+
warnings.simplefilter("ignore")
152+
import numpy.array_api
153+
147154
# Filter out annoying import messages. Want these in both develop and
148155
# release mode.
149156
pytest_args += [

0 commit comments

Comments
 (0)