Skip to content

Commit 01a05f0

Browse files
committed
Handle extension submodules properly in test_signatures
We still need to figure out how to make them optional, but at least the top-level submodule name check works correctly now.
1 parent 63296eb commit 01a05f0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

array_api_tests/test_signatures.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99
from . import function_stubs
1010

1111

12+
submodules = [m for m in dir(function_stubs) if
13+
inspect.ismodule(getattr(function_stubs, m)) and not
14+
m.startswith('_')]
15+
1216
def stub_module(name):
13-
submodules = [m for m in dir(function_stubs) if
14-
inspect.ismodule(getattr(function_stubs, m)) and not
15-
m.startswith('_')]
1617
for m in submodules:
1718
if name in getattr(function_stubs, m).__all__:
1819
return m
1920

21+
def extension_module(name):
22+
return name in submodules and name in function_stubs.__all__
23+
2024
def array_method(name):
2125
return stub_module(name) == 'array_object'
2226

@@ -111,7 +115,9 @@ def example_argument(arg, func_name, dtype):
111115

112116
@pytest.mark.parametrize('name', function_stubs.__all__)
113117
def test_has_names(name):
114-
if array_method(name):
118+
if extension_module(name):
119+
assert hasattr(mod, name), f'{mod_name} is missing the {name} extension'
120+
elif array_method(name):
115121
arr = ones((1,))
116122
if getattr(function_stubs.array_object, name) is None:
117123
assert hasattr(arr, name), f"The array object is missing the attribute {name}"

0 commit comments

Comments
 (0)