Skip to content

Commit 4e97da2

Browse files
committed
TST: replace (now-deprecared) suppress_warnings with stdlib warnings.filterwarnings WIP:
1 parent 2dab4c1 commit 4e97da2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

array_api_strict/tests/test_array_object.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import sys
2+
import warnings
23
import operator
34
from builtins import all as all_
45

5-
from numpy.testing import assert_raises, suppress_warnings
6+
from numpy.testing import assert_raises
67
import numpy as np
78
import pytest
89

@@ -269,10 +270,12 @@ def _check_op_array_scalar(dtypes, a, s, func, func_name, BIG_INT=BIG_INT):
269270

270271
else:
271272
# Only test for no error
272-
with suppress_warnings() as sup:
273+
with warnings.catch_warnings():
273274
# ignore warnings from pow(BIG_INT)
274-
sup.filter(RuntimeWarning,
275-
"invalid value encountered in power")
275+
warnings.filterwarnings(
276+
"ignore", category=RuntimeWarning,
277+
message="invalid value encountered in power"
278+
)
276279
func(s)
277280
return True
278281

array_api_strict/tests/test_elementwise_functions.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import warnings
12
from inspect import signature, getmodule
23

34
import numpy as np
45
import pytest
5-
from numpy.testing import suppress_warnings
66

77

88
from .. import asarray, _elementwise_functions
@@ -300,10 +300,13 @@ def _array_vals():
300300
if allowed:
301301
conv_scalar = a._promote_scalar(s)
302302

303-
with suppress_warnings() as sup:
303+
with warnings.catch_warnings():
304304
# ignore warnings from pow(BIG_INT)
305-
sup.filter(RuntimeWarning,
306-
"invalid value encountered in power")
305+
warnings.filterwarnings(
306+
"ignore", category=RuntimeWarning,
307+
message="invalid value encountered in power"
308+
)
309+
307310
assert func(s, a) == func(conv_scalar, a)
308311
assert func(a, s) == func(a, conv_scalar)
309312

0 commit comments

Comments
 (0)