Make it possible to format a param to a string, fixes #1074

This commit is contained in:
Dave Halter
2019-08-02 12:15:05 +02:00
parent a64ef2759c
commit 642e8f2aa6

View File

@@ -47,3 +47,16 @@ def test_param_default(Script, code, expected_params):
else: else:
annotation, = annotations annotation, = annotations
assert annotation.description == expected assert annotation.description == expected
@pytest.mark.parametrize(
'code, index, param_code, kind', [
('def f(x=1): ...\nf', 0, 'x=1', ...),
('def f(*args:int): ...\nf', 0, '*args: int', ...),
]
)
def test_param_kind_and_name(code, index, param_code, kind, Script, skip_python2):
func, = Script(code).goto_assignments()
sig, = func.get_signatures()
param = sig.params[index]
assert param.to_string() == param_code