Skip to content

Commit

Permalink
Added wrappers for os.statvfs() and os.path.ismount() (#162)
Browse files Browse the repository at this point in the history
* Added wrappers for os.statvfs() and os.path.ismount()

* Added tests for os.statvfs() and os.path.ismount()

* Added notes about os.statvfs() and os.path.ismount()
  • Loading branch information
mdevaev authored Aug 8, 2023
1 parent 564b11e commit ec8cc1e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ The `aiofiles.os` module contains executor-enabled coroutine versions of
several useful `os` functions that deal with files:

- `stat`
- `statvfs`
- `sendfile`
- `rename`
- `renames`
Expand All @@ -112,6 +113,7 @@ several useful `os` functions that deal with files:
- `path.isfile`
- `path.isdir`
- `path.islink`
- `path.ismount`
- `path.getsize`
- `path.getatime`
- `path.getctime`
Expand Down
1 change: 1 addition & 0 deletions src/aiofiles/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ async def run(*args, loop=None, executor=None, **kwargs):


stat = wrap(os.stat)
statvfs = wrap(os.statvfs)
rename = wrap(os.rename)
renames = wrap(os.renames)
replace = wrap(os.replace)
Expand Down
1 change: 1 addition & 0 deletions src/aiofiles/ospath.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
isfile = wrap(path.isfile)
isdir = wrap(path.isdir)
islink = wrap(path.islink)
ismount = wrap(path.ismount)
getsize = wrap(path.getsize)
getmtime = wrap(path.getmtime)
getatime = wrap(path.getatime)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ async def test_stat():
assert stat_res.st_size == 10


@pytest.mark.asyncio
async def test_statvfs():
"""Test the statvfs call."""

statvfs_res = await aiofiles.os.statvfs("/")

assert statvfs_res.f_bsize == os.statvfs("/").f_bsize


@pytest.mark.asyncio
async def test_remove():
"""Test the remove call."""
Expand Down Expand Up @@ -204,6 +213,14 @@ async def test_islink():
await aiofiles.os.remove(dst_filename)


@pytest.mark.asyncio
async def test_ismount():
"""Test the path.ismount call."""
filename = join(dirname(__file__), "resources")
assert not await aiofiles.os.path.ismount(filename)
assert await aiofiles.os.path.ismount("/")


@pytest.mark.asyncio
async def test_getsize():
"""Test path.getsize call."""
Expand Down

0 comments on commit ec8cc1e

Please sign in to comment.