mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-28 08:02:00 +00:00
Added unit test for list/vector of paths.
This commit is contained in:
parent
23ceaba974
commit
7d16bad5a9
@ -454,6 +454,13 @@ TEST_SUBMODULE(stl, m) {
|
|||||||
// test_fs_path
|
// test_fs_path
|
||||||
m.attr("has_filesystem") = true;
|
m.attr("has_filesystem") = true;
|
||||||
m.def("parent_path", [](const std::filesystem::path &p) { return p.parent_path(); });
|
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
|
#endif
|
||||||
|
|
||||||
#ifdef PYBIND11_TEST_VARIANT
|
#ifdef PYBIND11_TEST_VARIANT
|
||||||
|
@ -265,6 +265,11 @@ def test_fs_path(doc):
|
|||||||
doc(m.parent_path)
|
doc(m.parent_path)
|
||||||
== "parent_path(arg0: Union[os.PathLike, str, bytes]) -> 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>")
|
@pytest.mark.skipif(not hasattr(m, "load_variant"), reason="no <variant>")
|
||||||
|
Loading…
Reference in New Issue
Block a user