From ec8cc1e27b2ecd6346b24753a1b66fd60f6b7acc Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Wed, 9 Aug 2023 01:42:01 +0300 Subject: [PATCH] Added wrappers for os.statvfs() and os.path.ismount() (#162) * 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() --- README.md | 2 ++ src/aiofiles/os.py | 1 + src/aiofiles/ospath.py | 1 + tests/test_os.py | 17 +++++++++++++++++ 4 files changed, 21 insertions(+) diff --git a/README.md b/README.md index f3e5480..503d9f2 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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` diff --git a/src/aiofiles/os.py b/src/aiofiles/os.py index 66691fc..cedd05a 100644 --- a/src/aiofiles/os.py +++ b/src/aiofiles/os.py @@ -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) diff --git a/src/aiofiles/ospath.py b/src/aiofiles/ospath.py index a0a60f7..2a4bb3c 100644 --- a/src/aiofiles/ospath.py +++ b/src/aiofiles/ospath.py @@ -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) diff --git a/tests/test_os.py b/tests/test_os.py index 34b4b63..7aaac04 100644 --- a/tests/test_os.py +++ b/tests/test_os.py @@ -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.""" @@ -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."""