diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index dd93d51d0..08456b3c0 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -454,6 +454,13 @@ TEST_SUBMODULE(stl, m) { // test_fs_path m.attr("has_filesystem") = true; m.def("parent_path", [](const std::filesystem::path &p) { return p.parent_path(); }); + m.def("parent_paths", [](const std::vector &p) { + std::vector result; + for (const auto &i : p) { + result.push_back(i.parent_path()); + } + return result; + }); #endif #ifdef PYBIND11_TEST_VARIANT diff --git a/tests/test_stl.py b/tests/test_stl.py index d2d89420f..2c3172703 100644 --- a/tests/test_stl.py +++ b/tests/test_stl.py @@ -265,6 +265,11 @@ def test_fs_path(doc): doc(m.parent_path) == "parent_path(arg0: Union[os.PathLike, str, bytes]) -> Path" ) + assert m.parent_paths(["foo/bar", "foo/baz"]) == [Path("foo"), Path("foo")] + assert ( + doc(m.parent_paths) + == "parent_paths(arg0: list[Union[os.PathLike, str, bytes]]) -> list[Path]" + ) @pytest.mark.skipif(not hasattr(m, "load_variant"), reason="no ")