Skip to content

Commit

Permalink
Added OS-specific tests for
Browse files Browse the repository at this point in the history
  • Loading branch information
etianen committed Feb 21, 2024
1 parent 45f2012 commit 8b47648
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/trio/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = ()

Expand All @@ -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__ = ()

Expand Down
10 changes: 10 additions & 0 deletions src/trio/_tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8b47648

Please sign in to comment.