Example #1
0
def test_named_arguments(msg):
    assert kw_func0(5, 10) == "x=5, y=10"

    assert kw_func1(5, 10) == "x=5, y=10"
    assert kw_func1(5, y=10) == "x=5, y=10"
    assert kw_func1(y=10, x=5) == "x=5, y=10"

    assert kw_func2() == "x=100, y=200"
    assert kw_func2(5) == "x=5, y=200"
    assert kw_func2(x=5) == "x=5, y=200"
    assert kw_func2(y=10) == "x=100, y=10"
    assert kw_func2(5, 10) == "x=5, y=10"
    assert kw_func2(x=5, y=10) == "x=5, y=10"

    with pytest.raises(TypeError) as excinfo:
        # noinspection PyArgumentList
        kw_func2(x=5, y=10, z=12)
    assert msg(excinfo.value) == """
        kw_func2(): incompatible function arguments. The following argument types are supported:
            1. (x: int=100, y: int=200) -> str

        Invoked with:
    """

    assert kw_func4() == "{13 17}"
    assert kw_func4(myList=[1, 2, 3]) == "{1 2 3}"

    assert kw_func_udl(x=5, y=10) == "x=5, y=10"
    assert kw_func_udl_z(x=5) == "x=5, y=0"
def test_named_arguments(msg):
    assert kw_func0(5, 10) == "x=5, y=10"

    assert kw_func1(5, 10) == "x=5, y=10"
    assert kw_func1(5, y=10) == "x=5, y=10"
    assert kw_func1(y=10, x=5) == "x=5, y=10"

    assert kw_func2() == "x=100, y=200"
    assert kw_func2(5) == "x=5, y=200"
    assert kw_func2(x=5) == "x=5, y=200"
    assert kw_func2(y=10) == "x=100, y=10"
    assert kw_func2(5, 10) == "x=5, y=10"
    assert kw_func2(x=5, y=10) == "x=5, y=10"

    with pytest.raises(TypeError) as excinfo:
        # noinspection PyArgumentList
        kw_func2(x=5, y=10, z=12)
    assert msg(excinfo.value) == """
        kw_func2(): incompatible function arguments. The following argument types are supported:
            1. (x: int=100, y: int=200) -> str

        Invoked with:
    """

    assert kw_func4() == "{13 17}"
    assert kw_func4(myList=[1, 2, 3]) == "{1 2 3}"

    assert kw_func_udl(x=5, y=10) == "x=5, y=10"
    assert kw_func_udl_z(x=5) == "x=5, y=0"
def test_named_arguments(msg):
    assert kw_func0(5, 10) == "x=5, y=10"

    assert kw_func1(5, 10) == "x=5, y=10"
    assert kw_func1(5, y=10) == "x=5, y=10"
    assert kw_func1(y=10, x=5) == "x=5, y=10"

    assert kw_func2() == "x=100, y=200"
    assert kw_func2(5) == "x=5, y=200"
    assert kw_func2(x=5) == "x=5, y=200"
    assert kw_func2(y=10) == "x=100, y=10"
    assert kw_func2(5, 10) == "x=5, y=10"
    assert kw_func2(x=5, y=10) == "x=5, y=10"

    with pytest.raises(TypeError) as excinfo:
        # noinspection PyArgumentList
        kw_func2(x=5, y=10, z=12)
    assert excinfo.match(
        r'(?s)^kw_func2\(\): incompatible.*Invoked with: kwargs: ((x=5|y=10|z=12)(, |$))'
        + '{3}$')

    assert kw_func4() == "{13 17}"
    assert kw_func4(myList=[1, 2, 3]) == "{1 2 3}"

    assert kw_func_udl(x=5, y=10) == "x=5, y=10"
    assert kw_func_udl_z(x=5) == "x=5, y=0"
def test_named_arguments(msg):
    assert kw_func0(5, 10) == "x=5, y=10"

    assert kw_func1(5, 10) == "x=5, y=10"
    assert kw_func1(5, y=10) == "x=5, y=10"
    assert kw_func1(y=10, x=5) == "x=5, y=10"

    assert kw_func2() == "x=100, y=200"
    assert kw_func2(5) == "x=5, y=200"
    assert kw_func2(x=5) == "x=5, y=200"
    assert kw_func2(y=10) == "x=100, y=10"
    assert kw_func2(5, 10) == "x=5, y=10"
    assert kw_func2(x=5, y=10) == "x=5, y=10"

    with pytest.raises(TypeError) as excinfo:
        # noinspection PyArgumentList
        kw_func2(x=5, y=10, z=12)
    assert excinfo.match(
        r'(?s)^kw_func2\(\): incompatible.*Invoked with: kwargs: ((x=5|y=10|z=12)(, |$))' + '{3}$')

    assert kw_func4() == "{13 17}"
    assert kw_func4(myList=[1, 2, 3]) == "{1 2 3}"

    assert kw_func_udl(x=5, y=10) == "x=5, y=10"
    assert kw_func_udl_z(x=5) == "x=5, y=0"