diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 491f215cef..285f43b5b9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -156,6 +156,8 @@ set(PYBIND11_TEST_FILES test_tagbased_polymorphic test_thread test_union + test_unnamed_namespace_a + test_unnamed_namespace_b test_virtual_functions) # Invoking cmake with something like: diff --git a/tests/test_unnamed_namespace_a.cpp b/tests/test_unnamed_namespace_a.cpp new file mode 100644 index 0000000000..4f6472c386 --- /dev/null +++ b/tests/test_unnamed_namespace_a.cpp @@ -0,0 +1,9 @@ +#include "pybind11_tests.h" + +namespace { +struct any_struct {}; +} // namespace + +TEST_SUBMODULE(unnamed_namespace_a, m) { + py::class_(m, "unnamed_namespace_a_any_struct"); +} diff --git a/tests/test_unnamed_namespace_a.py b/tests/test_unnamed_namespace_a.py new file mode 100644 index 0000000000..b823376a4b --- /dev/null +++ b/tests/test_unnamed_namespace_a.py @@ -0,0 +1,5 @@ +from pybind11_tests import unnamed_namespace_a as m + + +def test_have_type(): + assert hasattr(m, "unnamed_namespace_a_any_struct") diff --git a/tests/test_unnamed_namespace_b.cpp b/tests/test_unnamed_namespace_b.cpp new file mode 100644 index 0000000000..8c9b140098 --- /dev/null +++ b/tests/test_unnamed_namespace_b.cpp @@ -0,0 +1,9 @@ +#include "pybind11_tests.h" + +namespace { +struct any_struct {}; +} // namespace + +TEST_SUBMODULE(unnamed_namespace_b, m) { + py::class_(m, "unnamed_namespace_b_any_struct"); +} diff --git a/tests/test_unnamed_namespace_b.py b/tests/test_unnamed_namespace_b.py new file mode 100644 index 0000000000..0550bc4347 --- /dev/null +++ b/tests/test_unnamed_namespace_b.py @@ -0,0 +1,5 @@ +from pybind11_tests import unnamed_namespace_b as m + + +def test_have_type(): + assert hasattr(m, "unnamed_namespace_b_any_struct")