Ejemplo n.º 1
0
def test_parse_arguments() -> None:
    async def func(arg1: str, arg2: int = 1) -> None:
        pass

    descriptions = {'arg1': 'HELLOOOOOOOOO'}
    required, optional = Module._parse_arguments(func, descriptions)  # noqa

    assert required.is_optional is False
    assert required.type == str
    assert required.name == 'arg1'
    assert required.description == descriptions['arg1']

    assert optional.is_optional is True
    assert optional.type == int
    assert optional.name == 'arg2'
    assert optional.description is None
Ejemplo n.º 2
0
def test_parse_arguments_fails() -> None:
    with pytest.raises(AssertionError):

        def func_with_args(*args: Any) -> None:
            pass

        Module._parse_arguments(func_with_args)  # noqa

    with pytest.raises(AssertionError):

        def func_with_kwargs(**kwargs: Any) -> None:
            pass

        Module._parse_arguments(func_with_kwargs)  # noqa

    with pytest.raises(AssertionError):

        def func_with_positional_only(a: Any, /, b: Any) -> None:  # noqa E225
            pass

        Module._parse_arguments(func_with_positional_only)  # noqa