Add a few tests for a previous assertion failure

This commit is contained in:
Dave Halter
2019-09-05 10:57:04 +02:00
parent 9c19f72af3
commit fbe58306c3
2 changed files with 22 additions and 2 deletions

View File

@@ -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):

View File

@@ -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