mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 14:59:27 +00:00
Add a std::filesystem::path <-> os.PathLike caster. (#2730)
This commit is contained in:
@@ -162,6 +162,25 @@ def test_exp_optional():
|
||||
assert holder.member_initialized()
|
||||
|
||||
|
||||
@pytest.mark.skipif(not hasattr(m, "has_filesystem"), reason="no <filesystem>")
|
||||
def test_fs_path():
|
||||
from pathlib import Path
|
||||
|
||||
class PseudoStrPath:
|
||||
def __fspath__(self):
|
||||
return "foo/bar"
|
||||
|
||||
class PseudoBytesPath:
|
||||
def __fspath__(self):
|
||||
return b"foo/bar"
|
||||
|
||||
assert m.parent_path(Path("foo/bar")) == Path("foo")
|
||||
assert m.parent_path("foo/bar") == Path("foo")
|
||||
assert m.parent_path(b"foo/bar") == Path("foo")
|
||||
assert m.parent_path(PseudoStrPath()) == Path("foo")
|
||||
assert m.parent_path(PseudoBytesPath()) == Path("foo")
|
||||
|
||||
|
||||
@pytest.mark.skipif(not hasattr(m, "load_variant"), reason="no <variant>")
|
||||
def test_variant(doc):
|
||||
assert m.load_variant(1) == "int"
|
||||
|
||||
Reference in New Issue
Block a user