From e5907480f58b4d2bde36813d10ae7ff7d2d2cbfb Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 29 Jun 2024 11:09:03 -0700 Subject: [PATCH] Add `py::class_` with default ctor. --- tests/test_wip.cpp | 16 +++++++++++++++- tests/test_wip.py | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/test_wip.cpp b/tests/test_wip.cpp index 3961bfdd5..04891a55e 100644 --- a/tests/test_wip.cpp +++ b/tests/test_wip.cpp @@ -1,3 +1,17 @@ #include "pybind11_tests.h" -TEST_SUBMODULE(wip, m) { m.attr("__doc__") = "WIP"; } +namespace pybind11_tests { +namespace wip { + +struct SomeType {}; + +} // namespace wip +} // namespace pybind11_tests + +TEST_SUBMODULE(wip, m) { + m.attr("__doc__") = "WIP"; + + using namespace pybind11_tests::wip; + + py::class_(m, "SomeType").def(py::init<>()); +} diff --git a/tests/test_wip.py b/tests/test_wip.py index 438b37202..3076c6fc7 100644 --- a/tests/test_wip.py +++ b/tests/test_wip.py @@ -5,3 +5,8 @@ from pybind11_tests import wip as m def test_doc(): assert m.__doc__ == "WIP" + + +def test_some_type_ctor(): + obj = m.SomeType() + assert isinstance(obj, m.SomeType)