Skip to content

Commit

Permalink
Add test_self_only_pos_only() in tests/test_methods_and_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
rwgk committed Nov 10, 2024
1 parent 5366b05 commit 34e808f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/test_methods_and_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ TEST_SUBMODULE(methods_and_attributes, m) {
static_cast<py::str (ExampleMandA::*)(int, int)>(
&ExampleMandA::overloaded));
})
.def("__str__", &ExampleMandA::toString)
.def("__str__", &ExampleMandA::toString, py::pos_only())
.def_readwrite("value", &ExampleMandA::value);

// test_copy_method
Expand Down
7 changes: 7 additions & 0 deletions tests/test_methods_and_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
)


def test_self_only_pos_only():
assert (
m.ExampleMandA.__str__.__doc__
== "__str__(self: pybind11_tests.methods_and_attributes.ExampleMandA, /) -> str\n"
)


def test_methods_and_attributes():
instance1 = m.ExampleMandA()
instance2 = m.ExampleMandA(32)
Expand Down

0 comments on commit 34e808f

Please sign in to comment.