Skip to content

Commit

Permalink
Added unit test for list/vector of paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
timohl committed Sep 6, 2024
1 parent 23ceaba commit 7d16bad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/test_stl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::filesystem::path> &p) {
std::vector<std::filesystem::path> result;
for (const auto &i : p) {
result.push_back(i.parent_path());
}
return result;
});
#endif

#ifdef PYBIND11_TEST_VARIANT
Expand Down
5 changes: 5 additions & 0 deletions tests/test_stl.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ def __fspath__(self):
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 <variant>")
Expand Down

0 comments on commit 7d16bad

Please sign in to comment.