@@ -21,6 +21,7 @@ def squeeze(x, /, axis):
21
21
22
22
"""
23
23
from collections import defaultdict
24
+ from copy import copy
24
25
from inspect import Parameter , Signature , signature
25
26
from types import FunctionType
26
27
from typing import Any , Callable , Dict , Literal , get_args
@@ -194,7 +195,7 @@ def _test_uninspectable_func(func_name: str, func: Callable, stub_sig: Signature
194
195
"manually to test the signature."
195
196
)
196
197
197
- argname_to_arg = func_to_specified_args [func_name ]
198
+ argname_to_arg = copy ( func_to_specified_args [func_name ])
198
199
argname_to_expr = func_to_specified_arg_exprs [func_name ]
199
200
for argname , expr in argname_to_expr .items ():
200
201
assert argname not in argname_to_arg .keys () # sanity check
@@ -238,8 +239,11 @@ def _test_uninspectable_func(func_name: str, func: Callable, stub_sig: Signature
238
239
if len (posorkw_args ) == 0 :
239
240
func (* posargs , ** kwargs )
240
241
else :
241
- func (* posargs , ** posorkw_args , ** kwargs )
242
- # TODO: test all positional and keyword permutations of pos-or-kw args
242
+ posorkw_name_to_arg_pairs = list (posorkw_args .items ())
243
+ for i in range (len (posorkw_name_to_arg_pairs ), - 1 , - 1 ):
244
+ extra_posargs = [arg for _ , arg in posorkw_name_to_arg_pairs [:i ]]
245
+ extra_kwargs = dict (posorkw_name_to_arg_pairs [i :])
246
+ func (* posargs , * extra_posargs , ** kwargs , ** extra_kwargs )
243
247
244
248
245
249
def _test_func_signature (func : Callable , stub : FunctionType , is_method = False ):
0 commit comments