Skip to content

Commit 5aa865d

Browse files
committed
Test info functions in the signature tests
1 parent 6737695 commit 5aa865d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

array_api_tests/test_signatures.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def squeeze(x, /, axis):
3131

3232
from . import dtype_helpers as dh
3333
from . import xp
34-
from .stubs import array_methods, category_to_funcs, extension_to_funcs, name_to_func
34+
from .stubs import (array_methods, category_to_funcs, extension_to_funcs,
35+
name_to_func, info_funcs)
3536

3637
ParameterKind = Literal[
3738
Parameter.POSITIONAL_ONLY,
@@ -307,3 +308,15 @@ def test_array_method_signature(stub: FunctionType):
307308
assert hasattr(x, stub.__name__), f"{stub.__name__} not found in array object {x!r}"
308309
method = getattr(x, stub.__name__)
309310
_test_func_signature(method, stub, is_method=True)
311+
312+
if info_funcs: # pytest fails collecting if info_funcs is empty
313+
@pytest.mark.min_version("2023.12")
314+
@pytest.mark.parametrize("stub", info_funcs, ids=lambda f: f.__name__)
315+
def test_info_func_signature(stub: FunctionType):
316+
try:
317+
info_namespace = xp.__array_namespace_info__()
318+
except Exception as e:
319+
raise AssertionError(f"Could not get info namespace from xp.__array_namespace_info__(): {e}")
320+
321+
func = getattr(info_namespace, stub.__name__)
322+
_test_func_signature(func, stub)

0 commit comments

Comments
 (0)