From fbe58306c309dad20b01baffd8984c7434cca07b Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 5 Sep 2019 10:57:04 +0200 Subject: [PATCH] Add a few tests for a previous assertion failure --- jedi/inference/star_args.py | 2 -- test/test_inference/test_signature.py | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/jedi/inference/star_args.py b/jedi/inference/star_args.py index 46ad1ddf..ef699dd7 100644 --- a/jedi/inference/star_args.py +++ b/jedi/inference/star_args.py @@ -47,8 +47,6 @@ def _iter_nodes_for_param(param_name): ) for c in values: yield c, args - else: - assert False def _goes_to_param_name(param_name, context, potential_name): diff --git a/test/test_inference/test_signature.py b/test/test_inference/test_signature.py index 8d9f2721..fc87c837 100644 --- a/test/test_inference/test_signature.py +++ b/test/test_inference/test_signature.py @@ -266,3 +266,25 @@ def test_dataclass_signature(Script, skip_pre_python37, start, start_params): assert quantity.name == 'int' price, = sig.params[-2].infer() assert price.name == 'float' + + +@pytest.mark.parametrize( + 'stmt, expected', [ + ('args = 1', 'wrapped(*args, b, c)'), + ('args = (1,)', 'wrapped(*args, c)'), + ('kwargs = 1', 'wrapped(b, /, **kwargs)'), + ('kwargs = dict(b=3)', 'wrapped(b, /, **kwargs)'), + ] +) +def test_param_resolving(Script, stmt, expected): + code = dedent('''\ + def full_redirect(func): + def wrapped(*args, **kwargs): + {stmt} + return func(1, *args, **kwargs) + return wrapped + def simple(a, b, *, c): ... + full_redirect(simple)('''.format(stmt=stmt)) + + sig, = Script(code).call_signatures() + assert sig.to_string() == expected