From d11022855c51d0b112dd05234809bab20b8bea5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francis=20Clairicia-Rose-Claire-Jos=C3=A9phine?= Date: Sun, 12 Nov 2023 01:22:52 +0100 Subject: [PATCH] CI: Run unit tests on Windows (#160) --- .github/codecov.yml | 2 +- .github/workflows/test.yml | 3 ++- src/easynetwork/lowlevel/asyncio/backend.py | 6 +----- .../test_backend/test_asyncio_backend.py | 15 --------------- .../test_asyncio_backend/test_stream.py | 2 ++ 5 files changed, 6 insertions(+), 22 deletions(-) diff --git a/.github/codecov.yml b/.github/codecov.yml index 7293e6e8..c1852048 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -1,7 +1,7 @@ comment: require_changes: false # Always show messages if codecov is triggered layout: "flags" # Only show coverage by flags - after_n_builds: 8 # nb_tested_python_version(==2) * (nb_tested_platforms(==3) + nb_unit_test_runs(==1)) + after_n_builds: 10 # nb_tested_python_version(==2) * (nb_functional_test_runs(==3) + nb_unit_test_runs(==2)) coverage: status: project: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c2075169..d61f6200 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,10 +43,11 @@ jobs: if: | (github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'Bump version:')) && (github.event_name != 'pull_request' || github.event.pull_request.draft != true) - runs-on: ubuntu-22.04 + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: + os: [ubuntu-22.04, windows-2022] python_version: ['3.11', '3.12'] steps: diff --git a/src/easynetwork/lowlevel/asyncio/backend.py b/src/easynetwork/lowlevel/asyncio/backend.py index 5b4c7b78..2cf894a5 100644 --- a/src/easynetwork/lowlevel/asyncio/backend.py +++ b/src/easynetwork/lowlevel/asyncio/backend.py @@ -90,11 +90,7 @@ def get_cancelled_exc_class(self) -> type[BaseException]: async def ignore_cancellation(self, coroutine: Coroutine[Any, Any, _T_co]) -> _T_co: if not asyncio.iscoroutine(coroutine): raise TypeError("Expected a coroutine object") - if sys.version_info >= (3, 12): - context = TaskUtils.current_asyncio_task().get_context() - else: - context = None - return await TaskUtils.cancel_shielded_await_task(asyncio.create_task(coroutine, context=context)) + return await TaskUtils.cancel_shielded_await_task(asyncio.create_task(coroutine)) def open_cancel_scope(self, *, deadline: float = math.inf) -> CancelScope: return CancelScope(deadline=deadline) diff --git a/tests/functional_test/test_async/test_backend/test_asyncio_backend.py b/tests/functional_test/test_async/test_backend/test_asyncio_backend.py index 19681d49..28532a7a 100644 --- a/tests/functional_test/test_async/test_backend/test_asyncio_backend.py +++ b/tests/functional_test/test_async/test_backend/test_asyncio_backend.py @@ -131,21 +131,6 @@ async def self_cancellation() -> None: await task assert task.cancelled() - @pytest.mark.xfail("sys.version_info < (3, 12)", reason="asyncio.Task.get_context() does not exist before Python 3.12") - async def test____ignore_cancellation____share_same_context_with_host_task( - self, - backend: AsyncIOBackend, - ) -> None: - async def coroutine() -> None: - await asyncio.sleep(0.1) - - cvar_for_test.set("after_in_coroutine") - - cvar_for_test.set("before_in_current_task") - await backend.ignore_cancellation(coroutine()) - - assert cvar_for_test.get() == "after_in_coroutine" - async def test____timeout____respected( self, backend: AsyncIOBackend, diff --git a/tests/unit_test/test_async/test_asyncio_backend/test_stream.py b/tests/unit_test/test_async/test_asyncio_backend/test_stream.py index 5930a662..733253b9 100644 --- a/tests/unit_test/test_async/test_asyncio_backend/test_stream.py +++ b/tests/unit_test/test_async/test_asyncio_backend/test_stream.py @@ -32,6 +32,7 @@ from pytest_mock import MockerFixture +from ....tools import PlatformMarkers from ...base import BaseTestSocket @@ -530,6 +531,7 @@ async def test____serve____connect____error_raised( exc, ) + @PlatformMarkers.skipif_platform_win32 @pytest.mark.parametrize("errno_value", sorted(ACCEPT_CAPACITY_ERRNOS), ids=errno_errorcode.__getitem__) async def test____serve____accept_capacity_error( self,