Skip to content

Commit 5c7074f

Browse files
committed
Fix the tests for Python 3.7
The array_api submodule needs to be skipped entirely, as it uses non-3.7 compatible syntax.
1 parent b6f71c8 commit 5c7074f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

numpy/_pytesttester.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,18 @@ def __call__(self, label='fast', verbose=1, extra_argv=None,
144144
# 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
147+
if sys.version_info >= (3, 8):
148+
# Ignore the warning from importing the array_api submodule. This
149+
# warning is done on import, so it would break pytest collection,
150+
# but importing it early here prevents the warning from being
151+
# issued when it imported again.
152+
warnings.simplefilter("ignore")
153+
import numpy.array_api
154+
else:
155+
# The array_api submodule is Python 3.8+ only due to the use
156+
# of positional-only argument syntax. We have to ignore it
157+
# completely or the tests will fail at the collection stage.
158+
pytest_args += ['--ignore-glob=numpy/array_api/*']
153159

154160
# Filter out annoying import messages. Want these in both develop and
155161
# release mode.

0 commit comments

Comments
 (0)