Skip to content

Commit

Permalink
Hotfix statvfs (#172)
Browse files Browse the repository at this point in the history
* Hotfix statvfs

* Try testing on Windows

* Tweak

* Skip statvfs test on Windows

* Lint

* Skip sendfile on Windows

* Tweak tests

* Skip test on Windows

* Skip some more Windows tests

* Tweak more tests

* Track coverage on Linux only

* Tweak quotes
  • Loading branch information
Tinche committed Aug 9, 2023
1 parent 6c083c9 commit a2720ff
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ on:
jobs:
tests:
name: "Python ${{ matrix.python-version }}"
runs-on: "ubuntu-latest"

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version:
["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.9"]

Expand All @@ -28,7 +28,6 @@ jobs:

- name: "Install dependencies"
run: |
set -xe
python -VV
python -m site
python -m pip install --upgrade pip wheel pdm
Expand All @@ -43,6 +42,7 @@ jobs:
name: "coverage-data"
path: ".coverage.*"
if-no-files-found: "ignore"
if: runner.os == 'Linux'

coverage:
name: "Combine & check coverage."
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ async def test_stuff():

### History

#### 23.2.1 (2023-08-09)

- Import `os.statvfs` conditionally to fix importing on non-UNIX systems.
[#171](https://github.com/Tinche/aiofiles/issues/171) [#172](https://github.com/Tinche/aiofiles/pull/172)

#### 23.2.0 (2023-08-09)

- aiofiles is now tested on Python 3.12 too.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "aiofiles"
version = "23.3.0dev0"
version = "23.2.1dev0"
description = "File support for asyncio."
authors = [
{name = "Tin Tvrtkovic", email = "tinchester@gmail.com"},
Expand Down
3 changes: 2 additions & 1 deletion src/aiofiles/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@


stat = wrap(os.stat)
statvfs = wrap(os.statvfs)
rename = wrap(os.rename)
renames = wrap(os.renames)
replace = wrap(os.replace)
Expand All @@ -48,3 +47,5 @@

if hasattr(os, "sendfile"):
sendfile = wrap(os.sendfile)
if hasattr(os, "statvfs"):
statvfs = wrap(os.statvfs)
11 changes: 10 additions & 1 deletion tests/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async def test_stat():
assert stat_res.st_size == 10


@pytest.mark.skipif(platform.system() == "Windows", reason="No statvfs on Windows")
@pytest.mark.asyncio
async def test_statvfs():
"""Test the statvfs call."""
Expand Down Expand Up @@ -118,7 +119,8 @@ async def test_replace():
reason="sendfile() syscall doesn't allow file->file",
)
@pytest.mark.skipif(
platform.system() == "Darwin", reason="sendfile() doesn't work on mac"
platform.system() in ("Darwin", "Windows"),
reason="sendfile() doesn't work on mac and Win",
)
@pytest.mark.asyncio
async def test_sendfile_file(tmpdir):
Expand Down Expand Up @@ -148,6 +150,9 @@ async def test_sendfile_file(tmpdir):
assert size == actual_size


@pytest.mark.skipif(
platform.system() in ("Windows"), reason="sendfile() doesn't work on Win"
)
@pytest.mark.asyncio
async def test_sendfile_socket(unused_tcp_port):
"""Test the sendfile functionality, file-to-socket."""
Expand Down Expand Up @@ -307,6 +312,9 @@ async def test_symlink():
assert exists(src_filename) and exists(dst_filename) is False


@pytest.mark.skipif(
platform.system() == "Windows", reason="Doesn't work on Win properly"
)
@pytest.mark.asyncio
async def test_readlink():
"""Test the readlink call."""
Expand Down Expand Up @@ -450,6 +458,7 @@ async def test_scandir_non_existing_dir():
await aiofiles.os.scandir(some_dir)


@pytest.mark.skipif(platform.system() == "Windows", reason="Doesn't work on Win")
@pytest.mark.asyncio
async def test_access():
temp_file = Path(__file__).parent.joinpath("resources", "os_access_temp.txt")
Expand Down
9 changes: 3 additions & 6 deletions tests/test_tempfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import io
import os
import platform
import sys

import pytest
Expand Down Expand Up @@ -120,14 +121,10 @@ async def test_spooled_temporary_file(mode):
assert await f.read() == data + data


@pytest.mark.asyncio
@pytest.mark.skipif(
sys.version_info < (3, 7),
reason=(
"text-mode SpooledTemporaryFile is implemented with StringIO in py3.6"
"it doesn't support `newlines`"
),
platform.system() == "Windows", reason="Doesn't work on Win properly"
)
@pytest.mark.asyncio
@pytest.mark.parametrize(
"test_string, newlines", [("LF\n", "\n"), ("CRLF\r\n", "\r\n")]
)
Expand Down

0 comments on commit a2720ff

Please sign in to comment.