def test_keyword_args_and_generalized_unpacking(): from pybind11_tests import (test_tuple_unpacking, test_dict_unpacking, test_keyword_args, test_unpacking_and_keywords1, test_unpacking_and_keywords2, test_unpacking_error1, test_unpacking_error2, test_arg_conversion_error1, test_arg_conversion_error2) def f(*args, **kwargs): return args, kwargs assert test_tuple_unpacking(f) == (("positional", 1, 2, 3, 4, 5, 6), {}) assert test_dict_unpacking(f) == (("positional", 1), {"key": "value", "a": 1, "b": 2}) assert test_keyword_args(f) == ((), {"x": 10, "y": 20}) assert test_unpacking_and_keywords1(f) == ((1, 2), {"c": 3, "d": 4}) assert test_unpacking_and_keywords2(f) == ( ("positional", 1, 2, 3, 4, 5), {"key": "value", "a": 1, "b": 2, "c": 3, "d": 4, "e": 5} ) with pytest.raises(TypeError) as excinfo: test_unpacking_error1(f) assert "Got multiple values for keyword argument" in str(excinfo.value) with pytest.raises(TypeError) as excinfo: test_unpacking_error2(f) assert "Got multiple values for keyword argument" in str(excinfo.value) with pytest.raises(RuntimeError) as excinfo: test_arg_conversion_error1(f) assert "Unable to convert call argument" in str(excinfo.value) with pytest.raises(RuntimeError) as excinfo: test_arg_conversion_error2(f) assert "Unable to convert call argument" in str(excinfo.value)