Skip to content

Commit

Permalink
Use catch_warnings(record=True) instead of simplefilter('ignore')
Browse files Browse the repository at this point in the history
There is a test that fails in the presence of simplefilter('ignore')
(test_warnings.py). catch_warnings(record=True) seems to be a way to get the
same behavior without failing the test.
  • Loading branch information
asmeurer committed Aug 23, 2021
1 parent 06ec0ec commit 7091e4c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/_pytesttester.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ def __call__(self, label='fast', verbose=1, extra_argv=None,
# so fetch module for suppression here.
from numpy.distutils import cpuinfo

with warnings.catch_warnings(record=True):
# 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
Expand Down

0 comments on commit 7091e4c

Please sign in to comment.