Skip to content

Commit 8b47648

Browse files
committed
Added OS-specific tests for
1 parent 45f2012 commit 8b47648

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/trio/_path.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,7 @@ def __repr__(self) -> str:
246246

247247
@final
248248
class PosixPath(Path, pathlib.PurePosixPath):
249-
"""An async :class:`pathlib.PosixPath` that executes blocking methods in :meth:`trio.to_thread.run_sync`.
250-
251-
"""
249+
"""An async :class:`pathlib.PosixPath` that executes blocking methods in :meth:`trio.to_thread.run_sync`."""
252250

253251
__slots__ = ()
254252

@@ -257,9 +255,7 @@ class PosixPath(Path, pathlib.PurePosixPath):
257255

258256
@final
259257
class WindowsPath(Path, pathlib.PureWindowsPath):
260-
"""An async :class:`pathlib.WindowsPath` that executes blocking methods in :meth:`trio.to_thread.run_sync`.
261-
262-
"""
258+
"""An async :class:`pathlib.WindowsPath` that executes blocking methods in :meth:`trio.to_thread.run_sync`."""
263259

264260
__slots__ = ()
265261

src/trio/_tests/test_path.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ def method_pair(
2727
return getattr(sync_path, method_name), getattr(async_path, method_name)
2828

2929

30+
@pytest.mark.skipif(os.name == "nt", reason="OS is not posix")
31+
async def test_instantiate_posix() -> None:
32+
assert isinstance(trio.Path(), trio.PosixPath)
33+
34+
35+
@pytest.mark.skipif(os.name != "nt", reason="OS is not Windows")
36+
async def test_instantiate_windows() -> None:
37+
assert isinstance(trio.Path(), trio.WindowsPath)
38+
39+
3040
async def test_open_is_async_context_manager(path: trio.Path) -> None:
3141
async with await path.open("w") as f:
3242
assert isinstance(f, AsyncIOWrapper)

0 commit comments

Comments
 (0)