From 3d252c3d7a79bcf48f9879a994546f81bd170938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 15:49:35 +0200 Subject: [PATCH 01/13] Hotfix statvfs --- README.md | 5 +++++ pyproject.toml | 2 +- src/aiofiles/os.py | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f8c87dc..d8cffd1 100644 --- a/README.md +++ b/README.md @@ -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) + #### 23.2.0 (2023-08-09) - aiofiles is now tested on Python 3.12 too. diff --git a/pyproject.toml b/pyproject.toml index ea660cc..ee8f97a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"}, diff --git a/src/aiofiles/os.py b/src/aiofiles/os.py index 6da4255..29bc748 100644 --- a/src/aiofiles/os.py +++ b/src/aiofiles/os.py @@ -29,7 +29,6 @@ stat = wrap(os.stat) -statvfs = wrap(os.statvfs) rename = wrap(os.rename) renames = wrap(os.renames) replace = wrap(os.replace) @@ -48,3 +47,5 @@ if hasattr(os, "sendfile"): sendfile = wrap(os.sendfile) +if hasattr(os, "statvfs"): + statvfs = wrap(os.statvfs) From 5c2c8647e329a1860e79a9f2fb37ac9dfa5d85c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 15:52:48 +0200 Subject: [PATCH 02/13] Try testing on Windows --- .github/workflows/main.yml | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9df332c..bc03bd3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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"] diff --git a/README.md b/README.md index d8cffd1..822ddc0 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ async def test_stuff(): #### 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) + [#171](https://github.com/Tinche/aiofiles/issues/171) [#172](https://github.com/Tinche/aiofiles/pull/172) #### 23.2.0 (2023-08-09) From ac194121777bcfdc52f0c3dc13fa80ca171e7aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 15:55:27 +0200 Subject: [PATCH 03/13] Tweak --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc03bd3..6683b7e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,6 @@ jobs: - name: "Install dependencies" run: | - set -xe python -VV python -m site python -m pip install --upgrade pip wheel pdm From c8c5f250c55fc8ee7d5e6fc28277a0faf0e83473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 15:58:54 +0200 Subject: [PATCH 04/13] Skip statvfs test on Windows --- tests/test_os.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_os.py b/tests/test_os.py index 0419c22..5672a9a 100644 --- a/tests/test_os.py +++ b/tests/test_os.py @@ -21,6 +21,9 @@ 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.""" From 4182dd7b4b71ae7fd5928a6b0170d8ac93850a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 16:02:07 +0200 Subject: [PATCH 05/13] Lint --- tests/test_os.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_os.py b/tests/test_os.py index 5672a9a..d93bb79 100644 --- a/tests/test_os.py +++ b/tests/test_os.py @@ -21,9 +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.skipif(platform.system() == "Windows", reason="No statvfs on Windows") @pytest.mark.asyncio async def test_statvfs(): """Test the statvfs call.""" From c33ed0c9044ecab5f1258e1c6da2d9d3f758a83d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 16:07:21 +0200 Subject: [PATCH 06/13] Skip sendfile on Windows --- tests/test_os.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_os.py b/tests/test_os.py index d93bb79..53f8c9c 100644 --- a/tests/test_os.py +++ b/tests/test_os.py @@ -119,7 +119,7 @@ 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" ) @pytest.mark.asyncio async def test_sendfile_file(tmpdir): From 658e61a72237a6de2969ca39f28f69593805a4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 16:15:07 +0200 Subject: [PATCH 07/13] Tweak tests --- tests/test_os.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_os.py b/tests/test_os.py index 53f8c9c..9b283d5 100644 --- a/tests/test_os.py +++ b/tests/test_os.py @@ -119,7 +119,8 @@ async def test_replace(): reason="sendfile() syscall doesn't allow file->file", ) @pytest.mark.skipif( - platform.system() in ("Darwin", "Windows"), 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): @@ -149,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.""" From fbd267b0b7c0aa0b0543812f77d06933b94cdde7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 16:19:19 +0200 Subject: [PATCH 08/13] Skip test on Windows --- tests/test_os.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_os.py b/tests/test_os.py index 9b283d5..9e9573e 100644 --- a/tests/test_os.py +++ b/tests/test_os.py @@ -455,6 +455,7 @@ async def test_scandir_non_existing_dir(): await aiofiles.os.scandir(some_dir) +@pytest.mark.skipif(platform.system() in ("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") From a6ddeda146f21e42cd8069aed5fcbac619ca8c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 16:32:08 +0200 Subject: [PATCH 09/13] Skip some more Windows tests --- tests/test_os.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_os.py b/tests/test_os.py index 9e9573e..d3c0bda 100644 --- a/tests/test_os.py +++ b/tests/test_os.py @@ -312,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.""" @@ -455,7 +458,7 @@ async def test_scandir_non_existing_dir(): await aiofiles.os.scandir(some_dir) -@pytest.mark.skipif(platform.system() in ("Windows"), reason="Doesn't work on Win") +@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") From adf7f01ef25dbc56996049521c73aef16345ff20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 16:35:29 +0200 Subject: [PATCH 10/13] Tweak more tests --- tests/test_tempfile.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/test_tempfile.py b/tests/test_tempfile.py index 36c63cc..b4d6ffd 100644 --- a/tests/test_tempfile.py +++ b/tests/test_tempfile.py @@ -1,5 +1,6 @@ import io import os +import platform import sys import pytest @@ -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")] ) From d387f7cd21ab22168d85ea4e4c428cc95d7730d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 17:07:20 +0200 Subject: [PATCH 11/13] Track coverage on Linux only --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6683b7e..cb84861 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,6 +42,7 @@ jobs: name: "coverage-data" path: ".coverage.*" if-no-files-found: "ignore" + if: runner.os == "Linux" coverage: name: "Combine & check coverage." From 3fd9e83b9eb3df155d795f1507d66b0c6a137a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 17:11:32 +0200 Subject: [PATCH 12/13] Tweak quotes --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb84861..06070d3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,7 +42,7 @@ jobs: name: "coverage-data" path: ".coverage.*" if-no-files-found: "ignore" - if: runner.os == "Linux" + if: runner.os == 'Linux' coverage: name: "Combine & check coverage." From df7f204cee3fd98bd95917139588c013c3075b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 9 Aug 2023 17:15:42 +0200 Subject: [PATCH 13/13] Update changlog --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 822ddc0..2e40191 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,7 @@ async def test_stuff(): - 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) +- aiofiles is now also tested on Windows. #### 23.2.0 (2023-08-09)