Skip to content

Commit

Permalink
Add async remove function
Browse files Browse the repository at this point in the history
Relevent test is also added
  • Loading branch information
harryzcy authored and Tinche committed Apr 9, 2019
1 parent 9cf2ac8 commit a60f19b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions aiofiles/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def run(*args, loop=None, executor=None, **kwargs):


stat = wrap(os.stat)
remove = wrap(os.remove)

if hasattr(os, "sendfile"):
sendfile = wrap(os.sendfile)
14 changes: 13 additions & 1 deletion tests/test_os.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests for asyncio's os module."""
import aiofiles.os
import asyncio
from os.path import join, dirname
from os.path import join, dirname, exists
import pytest
import platform

Expand All @@ -17,6 +17,18 @@ def test_stat():
assert stat_res.st_size == 10


@asyncio.coroutine
@pytest.mark.asyncio
def test_remove():
"""Test the remove call."""
filename = join(dirname(__file__), 'resources', 'test_file2.txt')
with open(filename, 'w') as f:
f.write('Test file for remove call')

assert exists(filename)
yield from aiofiles.os.remove(filename)
assert exists(filename) is False

@asyncio.coroutine
@pytest.mark.skipif('2.4' < platform.release() < '2.6.33',
reason = "sendfile() syscall doesn't allow file->file")
Expand Down

0 comments on commit a60f19b

Please sign in to comment.