Skip to content

Commit

Permalink
Added ruff formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyas829 committed Oct 2, 2024
1 parent 3eafa0b commit 64d9635
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@ async def test_ensure_directory_absent(tmp_path: pathlib.Path):
await ensure_absent(path)
assert not await aiofiles.os.path.exists(path)


@pytest.mark.asyncio
async def test_ensure_file_absent_when_open_for_reading(tmp_path: pathlib.Path):
path = tmp_path / "test_file"
async with aiofiles.open(path, "w") as test_file:
await test_file.write("foobar")

# Open the file for reading
async with aiofiles.open(path, "r"):
pass # Simply open and close the file

# Ensure the file is removed
await ensure_absent(path)
assert not await aiofiles.os.path.exists(path)



@pytest.mark.asyncio
async def test_ensure_non_empty_directory_absent(tmp_path: pathlib.Path):
# Create a directory
Expand All @@ -63,7 +65,8 @@ async def test_ensure_non_empty_directory_absent(tmp_path: pathlib.Path):

# The directory should still exist since it was not removed
assert await aiofiles.os.path.exists(path)



@pytest.mark.asyncio
async def test_ensure_invalid_path(tmp_path: pathlib.Path):
# Create an invalid path (e.g., a socket or a broken symlink)
Expand Down Expand Up @@ -92,7 +95,8 @@ async def test_ensure_absent_called_on_symlink(tmp_path: pathlib.Path):

# Original file should still exist
assert await aiofiles.os.path.exists(path)



@pytest.mark.asyncio
async def test_ensure_absent_removes_nested_empty_directory(tmp_path: pathlib.Path):
# Create a nested directory structure
Expand All @@ -105,4 +109,3 @@ async def test_ensure_absent_removes_nested_empty_directory(tmp_path: pathlib.Pa

# Ensure parent directory still exists
assert await aiofiles.os.path.exists(tmp_path / "dir1")

0 comments on commit 64d9635

Please sign in to comment.