Skip to content

Commit 206f666

Browse files
committed
Handle functions with keyword-only arguments without defaults
1 parent 8f722e7 commit 206f666

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

array_api_tests/test_signatures.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,12 @@ def test_function_positional_args(name):
155155
# Duplicate the last positional argument for the n+1 test.
156156
args = args + [args[-1]]
157157

158+
kwonlydefaults = argspec.kwonlydefaults or {}
159+
required_kwargs = {arg: example_argument(arg, name, dtype) for arg in argspec.kwonlyargs if arg not in kwonlydefaults}
160+
158161
for n in range(nargs[0]+2):
159162
if n in nargs:
160-
doesnt_raise(lambda: mod_func(*args[:n]))
163+
doesnt_raise(lambda: mod_func(*args[:n], **required_kwargs))
161164
elif argspec.varargs:
162165
pass
163166
else:
@@ -183,7 +186,7 @@ def test_function_keyword_only_args(name):
183186
if name.startswith('__'):
184187
args = args[1:]
185188
kwonlyargs = argspec.kwonlyargs
186-
kwonlydefaults = argspec.kwonlydefaults
189+
kwonlydefaults = argspec.kwonlydefaults or {}
187190
dtype = None
188191

189192
args = [example_argument(arg, name, dtype) for arg in args]

0 commit comments

Comments
 (0)