From 7f02b5b7ec569d99bf9ac00fc09d381f07003771 Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Mon, 13 Apr 2026 12:24:52 +0200 Subject: [PATCH] Add tests for core.python.arguments.PythonFunctionArgument.signature_repr --- .../arguments/test_PythonFunctionArgument.py | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/unit/core/python/arguments/test_PythonFunctionArgument.py b/tests/unit/core/python/arguments/test_PythonFunctionArgument.py index b242fd3..4439576 100644 --- a/tests/unit/core/python/arguments/test_PythonFunctionArgument.py +++ b/tests/unit/core/python/arguments/test_PythonFunctionArgument.py @@ -133,4 +133,25 @@ def test_PythonFunctionArgument(name, kind, default, annotation): '_', ]) def test_PythonFunctionArgument_asterik(name, kind, annotation): - PythonFunctionArgument(name, kind, None, annotation) \ No newline at end of file + PythonFunctionArgument(name, kind, None, annotation) + +@pytest.mark.parametrize('argument,expected', [ + (PythonFunctionArgument('a', PythonArgumentKind.NORMAL, None, None), 'a'), + (PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '1', None), 'a = 1'), + (PythonFunctionArgument('a', PythonArgumentKind.NORMAL, None, 'int'), 'a: int'), + (PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '1', 'int'), 'a: int = 1'), + (PythonFunctionArgument('a', PythonArgumentKind.POSITIONAL_ONLY, None, None), 'a'), + (PythonFunctionArgument('a', PythonArgumentKind.POSITIONAL_ONLY, '1', None), 'a = 1'), + (PythonFunctionArgument('a', PythonArgumentKind.POSITIONAL_ONLY, None, 'int'), 'a: int'), + (PythonFunctionArgument('a', PythonArgumentKind.POSITIONAL_ONLY, '1', 'int'), 'a: int = 1'), + (PythonFunctionArgument('a', PythonArgumentKind.KEYWORD_ONLY, None, None), 'a'), + (PythonFunctionArgument('a', PythonArgumentKind.KEYWORD_ONLY, '1', None), 'a = 1'), + (PythonFunctionArgument('a', PythonArgumentKind.KEYWORD_ONLY, None, 'int'), 'a: int'), + (PythonFunctionArgument('a', PythonArgumentKind.KEYWORD_ONLY, '1', 'int'), 'a: int = 1'), + (PythonFunctionArgument('a', PythonArgumentKind.VARARG, None, None), '*a'), + (PythonFunctionArgument('a', PythonArgumentKind.VARARG, None, 'int'), '*a: int'), + (PythonFunctionArgument('a', PythonArgumentKind.KWARGS, None, None), '**a'), + (PythonFunctionArgument('a', PythonArgumentKind.KWARGS, None, 'int'), '**a: int'), +]) +def test_PythonFunctionArgument_signature_repr(argument, expected): + assert argument.signature_repr() == expected \ No newline at end of file