summaryrefslogtreecommitdiff
path: root/tests/py3/test_util_inspect_py3.py
blob: 6d02025f9a8a212529c0601f4218498e8e35aae9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-
"""
    py3/test_util_inspect
    ~~~~~~~~~~~~~~~~~~~~~

    Tests util.inspect functions.

    :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

from sphinx.util import inspect


def test_Signature_keyword_only_arguments():
    def func1(arg1, arg2, *, arg3=None, arg4=None):
        pass

    def func2(*, arg3, arg4):
        pass

    sig = inspect.Signature(func1).format_args()
    assert sig == '(arg1, arg2, *, arg3=None, arg4=None)'

    sig = inspect.Signature(func2).format_args()
    assert sig == '(*, arg3, arg4)'