diff --git a/src/trio/_path.py b/src/trio/_path.py index fc43aa2712..cb19008d54 100644 --- a/src/trio/_path.py +++ b/src/trio/_path.py @@ -246,9 +246,7 @@ def __repr__(self) -> str: @final class PosixPath(Path, pathlib.PurePosixPath): - """An async :class:`pathlib.PosixPath` that executes blocking methods in :meth:`trio.to_thread.run_sync`. - - """ + """An async :class:`pathlib.PosixPath` that executes blocking methods in :meth:`trio.to_thread.run_sync`.""" __slots__ = () @@ -257,9 +255,7 @@ class PosixPath(Path, pathlib.PurePosixPath): @final class WindowsPath(Path, pathlib.PureWindowsPath): - """An async :class:`pathlib.WindowsPath` that executes blocking methods in :meth:`trio.to_thread.run_sync`. - - """ + """An async :class:`pathlib.WindowsPath` that executes blocking methods in :meth:`trio.to_thread.run_sync`.""" __slots__ = () diff --git a/src/trio/_tests/test_path.py b/src/trio/_tests/test_path.py index ed7ace2af7..21ebefc90d 100644 --- a/src/trio/_tests/test_path.py +++ b/src/trio/_tests/test_path.py @@ -27,6 +27,16 @@ def method_pair( return getattr(sync_path, method_name), getattr(async_path, method_name) +@pytest.mark.skipif(os.name == "nt", reason="OS is not posix") +async def test_instantiate_posix() -> None: + assert isinstance(trio.Path(), trio.PosixPath) + + +@pytest.mark.skipif(os.name != "nt", reason="OS is not Windows") +async def test_instantiate_windows() -> None: + assert isinstance(trio.Path(), trio.WindowsPath) + + async def test_open_is_async_context_manager(path: trio.Path) -> None: async with await path.open("w") as f: assert isinstance(f, AsyncIOWrapper)