Added test case

This commit is contained in:
gentlegiantJGC 2024-09-20 18:57:50 +01:00
parent 14cde218ef
commit 82906b97c1
2 changed files with 17 additions and 0 deletions

View File

@ -322,4 +322,16 @@ TEST_SUBMODULE(kwargs_and_defaults, m) {
py::pos_only{},
py::arg("i"),
py::arg("j"));
// Test support for args and kwargs subclasses
class ArgsSubclass: public py::args{
using py::args::args;
}
class KWArgsSubclass: public py::kwargs{
using py::kwargs::kwargs;
}
m.def("args_kwargs_subclass_function", [](const ArgsSubclass &args, const KWArgsSubclass &kwargs) {
return py::make_tuple(args, kwargs);
});
}

View File

@ -426,3 +426,8 @@ def test_args_refcount():
assert m.mixed_args_refcount(myval, myval, myval) == (exp3_3, exp3_3, exp3_3)
assert m.class_default_argument() == "<class 'decimal.Decimal'>"
assert m.args_kwargs_subclass_function(7, 8, myval, a=1, b=myval) == (
(7, 8, myval),
{"a": 1, "b": myval},
)