diff options
author | Aaron Meurer <asmeurer@gmail.com> | 2021-08-06 16:10:09 -0600 |
---|---|---|
committer | Aaron Meurer <asmeurer@gmail.com> | 2021-08-06 16:10:09 -0600 |
commit | b6f71c8fc742e09d803c99fe41c06d6f2a81d4de (patch) | |
tree | f5f52bb331c7b813a136faf1d0ab8c03cc4840b2 /numpy/_pytesttester.py | |
parent | fcdadee7815cbb72a1036c0ef144d73e916eae6d (diff) | |
download | numpy-b6f71c8fc742e09d803c99fe41c06d6f2a81d4de.tar.gz |
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.
Diffstat (limited to 'numpy/_pytesttester.py')
-rw-r--r-- | numpy/_pytesttester.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/numpy/_pytesttester.py b/numpy/_pytesttester.py index acfaa1ca5..bfcbd4f1f 100644 --- a/numpy/_pytesttester.py +++ b/numpy/_pytesttester.py @@ -137,13 +137,20 @@ class PytestTester: # offset verbosity. The "-q" cancels a "-v". pytest_args += ["-q"] - # Filter out distutils cpu warnings (could be localized to - # distutils tests). ASV has problems with top level import, - # so fetch module for suppression here. with warnings.catch_warnings(): warnings.simplefilter("always") + # Filter out distutils cpu warnings (could be localized to + # distutils tests). ASV has problems with top level import, + # so fetch module for suppression here. from numpy.distutils import cpuinfo + # Ignore the warning from importing the array_api submodule. This + # warning is done on import, so it would break pytest collection, + # but importing it early here prevents the warning from being + # issued when it imported again. + warnings.simplefilter("ignore") + import numpy.array_api + # Filter out annoying import messages. Want these in both develop and # release mode. pytest_args += [ |