Skip to content

Commit

Permalink
Add aiofiles.os.renames function
Browse files Browse the repository at this point in the history
  • Loading branch information
jpy-git authored and Tinche committed Jan 3, 2022
1 parent d2a367e commit 584d5c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/aiofiles/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async def run(*args, loop=None, executor=None, **kwargs):

stat = wrap(os.stat)
rename = wrap(os.rename)
renames = wrap(os.renames)
replace = wrap(os.replace)
remove = wrap(os.remove)
mkdir = wrap(os.mkdir)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ async def test_rename():
assert exists(old_filename) and exists(new_filename) is False


@pytest.mark.asyncio
async def test_renames():
"""Test the renames call."""
old_filename = join(dirname(__file__), "resources", "test_file1.txt")
new_filename = join(
dirname(__file__), "resources", "subdirectory", "test_file2.txt"
)
await aiofiles.os.renames(old_filename, new_filename)
assert exists(old_filename) is False and exists(new_filename)
await aiofiles.os.renames(new_filename, old_filename)
assert (
exists(old_filename) and
exists(new_filename) is False and
exists(dirname(new_filename)) is False
)


@pytest.mark.asyncio
async def test_replace():
"""Test the replace call."""
Expand Down

0 comments on commit 584d5c9

Please sign in to comment.