Skip to content

Commit f5fbf78

Browse files
committed
Silence warnings output in the tests
1 parent e24f55e commit f5fbf78

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

array_api_strict/tests/test_array_object.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,8 @@ def test_array_namespace():
410410
assert a.__array_namespace__(api_version="2022.12") is array_api_strict
411411
assert array_api_strict.__array_api_version__ == "2022.12"
412412

413-
assert a.__array_namespace__(api_version="2023.12") is array_api_strict
413+
with pytest.warns(UserWarning):
414+
assert a.__array_namespace__(api_version="2023.12") is array_api_strict
414415
assert array_api_strict.__array_api_version__ == "2023.12"
415416

416417
with pytest.warns(UserWarning):

array_api_strict/tests/test_elementwise_functions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
)
1313
from .._flags import set_array_api_strict_flags
1414

15+
import pytest
16+
1517
def nargs(func):
1618
return len(getfullargspec(func).args)
1719

@@ -101,7 +103,8 @@ def _array_vals():
101103
yield asarray(1.0, dtype=d)
102104

103105
# Use the latest version of the standard so all functions are included
104-
set_array_api_strict_flags(api_version="2023.12")
106+
with pytest.warns(UserWarning):
107+
set_array_api_strict_flags(api_version="2023.12")
105108

106109
for x in _array_vals():
107110
for func_name, types in elementwise_function_input_types.items():

array_api_strict/tests/test_flags.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ def test_flags():
7373
set_array_api_strict_flags(api_version='2020.12'))
7474
pytest.raises(ValueError, lambda: set_array_api_strict_flags(
7575
enabled_extensions=('linalg', 'fft', 'invalid')))
76-
pytest.raises(ValueError, lambda: set_array_api_strict_flags(
77-
api_version='2021.12',
78-
enabled_extensions=('linalg', 'fft')))
76+
with pytest.warns(UserWarning):
77+
pytest.raises(ValueError, lambda: set_array_api_strict_flags(
78+
api_version='2021.12',
79+
enabled_extensions=('linalg', 'fft')))
7980

8081
# Test resetting flags
8182
with pytest.warns(UserWarning):
@@ -96,7 +97,8 @@ def test_api_version():
9697
assert xp.__array_api_version__ == '2022.12'
9798

9899
# Test setting the version
99-
set_array_api_strict_flags(api_version='2021.12')
100+
with pytest.warns(UserWarning):
101+
set_array_api_strict_flags(api_version='2021.12')
100102
assert xp.__array_api_version__ == '2021.12'
101103

102104
def test_data_dependent_shapes():

0 commit comments

Comments
 (0)