From bfb54b0969331b999d076128073343381f3f643a Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Sat, 17 Dec 2022 23:46:22 +0200 Subject: [PATCH] Test for 3.11 support (#2612) Co-authored-by: Zhiwei --- .github/workflows/pr-bandit.yml | 1 + .github/workflows/pr-docs.yml | 2 +- .github/workflows/pr-linter.yml | 2 +- .github/workflows/pr-python311.yml | 47 +++++++++++++++++++++++++++ .github/workflows/pr-type-check.yml | 1 + .github/workflows/pr-windows.yml | 1 + .github/workflows/publish-images.yml | 2 +- .github/workflows/publish-package.yml | 2 +- pyproject.toml | 1 + sanic/blueprints.py | 2 +- setup.py | 1 + tests/test_signals.py | 4 +-- tox.ini | 6 ++-- 13 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/pr-python311.yml diff --git a/.github/workflows/pr-bandit.yml b/.github/workflows/pr-bandit.yml index 2bd70204..92dc8991 100644 --- a/.github/workflows/pr-bandit.yml +++ b/.github/workflows/pr-bandit.yml @@ -20,6 +20,7 @@ jobs: - { python-version: 3.8, tox-env: security} - { python-version: 3.9, tox-env: security} - { python-version: "3.10", tox-env: security} + - { python-version: "3.11", tox-env: security} steps: - name: Checkout the repository uses: actions/checkout@v2 diff --git a/.github/workflows/pr-docs.yml b/.github/workflows/pr-docs.yml index 8479aef5..26af6308 100644 --- a/.github/workflows/pr-docs.yml +++ b/.github/workflows/pr-docs.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: config: - - {python-version: "3.8", tox-env: "docs"} + - {python-version: "3.10", tox-env: "docs"} fail-fast: false diff --git a/.github/workflows/pr-linter.yml b/.github/workflows/pr-linter.yml index 11ad9d29..655beffa 100644 --- a/.github/workflows/pr-linter.yml +++ b/.github/workflows/pr-linter.yml @@ -16,7 +16,7 @@ jobs: matrix: os: [ubuntu-latest] config: - - { python-version: 3.8, tox-env: lint} + - { python-version: "3.10", tox-env: lint} steps: - name: Checkout the repository uses: actions/checkout@v2 diff --git a/.github/workflows/pr-python311.yml b/.github/workflows/pr-python311.yml new file mode 100644 index 00000000..f0aa49c9 --- /dev/null +++ b/.github/workflows/pr-python311.yml @@ -0,0 +1,47 @@ +name: Python 3.11 Tests +on: + pull_request: + branches: + - main + - "*LTS" + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + testPy311: + if: github.event.pull_request.draft == false + name: ut-${{ matrix.config.tox-env }}-${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] + config: + - { + python-version: "3.11", + tox-env: py311, + ignore-error-flake: "false", + command-timeout: "0", + } + - { + python-version: "3.11", + tox-env: py311-no-ext, + ignore-error-flake: "true", + command-timeout: "600000", + } + steps: + - name: Checkout the Repository + uses: actions/checkout@v2 + id: checkout-branch + + - name: Run Unit Tests + uses: harshanarayana/custom-actions@main + with: + python-version: ${{ matrix.config.python-version }} + test-infra-tool: tox + test-infra-version: latest + action: tests + test-additional-args: "-e=${{ matrix.config.tox-env }},-vv=''" + experimental-ignore-error: "${{ matrix.config.ignore-error-flake }}" + command-timeout: "${{ matrix.config.command-timeout }}" + test-failure-retry: "3" diff --git a/.github/workflows/pr-type-check.yml b/.github/workflows/pr-type-check.yml index 58a90ee3..27511c74 100644 --- a/.github/workflows/pr-type-check.yml +++ b/.github/workflows/pr-type-check.yml @@ -20,6 +20,7 @@ jobs: - { python-version: 3.8, tox-env: type-checking} - { python-version: 3.9, tox-env: type-checking} - { python-version: "3.10", tox-env: type-checking} + - { python-version: "3.11", tox-env: type-checking} steps: - name: Checkout the repository uses: actions/checkout@v2 diff --git a/.github/workflows/pr-windows.yml b/.github/workflows/pr-windows.yml index 050ee2bb..ca8b5879 100644 --- a/.github/workflows/pr-windows.yml +++ b/.github/workflows/pr-windows.yml @@ -19,6 +19,7 @@ jobs: - { python-version: 3.8, tox-env: py38-no-ext } - { python-version: 3.9, tox-env: py39-no-ext } - { python-version: "3.10", tox-env: py310-no-ext } + - { python-version: "3.11", tox-env: py310-no-ext } - { python-version: pypy-3.7, tox-env: pypy37-no-ext } steps: diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml index 621f34a0..48454e1e 100644 --- a/.github/workflows/publish-images.yml +++ b/.github/workflows/publish-images.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - name: Checkout repository diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index faa3b7e6..551e7200 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: ["3.8"] + python-version: ["3.10"] steps: - name: Checkout Repository diff --git a/pyproject.toml b/pyproject.toml index 35d82408..bd12b39b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,5 +22,6 @@ module = [ "httptools.*", "trustme.*", "sanic_routing.*", + "aioquic.*", ] ignore_missing_imports = true diff --git a/sanic/blueprints.py b/sanic/blueprints.py index 0cca4bd4..5699d4bc 100644 --- a/sanic/blueprints.py +++ b/sanic/blueprints.py @@ -442,7 +442,7 @@ class Blueprint(BaseSanic): events.add(signal.ctx.event) return asyncio.wait( - [event.wait() for event in events], + [asyncio.create_task(event.wait()) for event in events], return_when=asyncio.FIRST_COMPLETED, timeout=timeout, ) diff --git a/setup.py b/setup.py index a8bd760a..6542986d 100644 --- a/setup.py +++ b/setup.py @@ -90,6 +90,7 @@ setup_kwargs = { "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ], "entry_points": {"console_scripts": ["sanic = sanic.__main__:main"]}, } diff --git a/tests/test_signals.py b/tests/test_signals.py index af31fbcd..49a684e7 100644 --- a/tests/test_signals.py +++ b/tests/test_signals.py @@ -314,10 +314,10 @@ async def test_dispatch_signal_triggers_event_on_bp(app): waiter = bp.event("foo.bar.baz") assert isawaitable(waiter) - fut = asyncio.ensure_future(do_wait()) + fut = do_wait() for signal in signal_group: signal.ctx.event.set() - await fut + await asyncio.gather(fut) assert bp_counter == 1 diff --git a/tox.ini b/tox.ini index af4b7439..27e19b6c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,11 @@ [tox] -envlist = py37, py38, py39, py310, pyNightly, pypy37, {py37,py38,py39,py310,pyNightly,pypy37}-no-ext, lint, check, security, docs, type-checking +envlist = py37, py38, py39, py310, py311, pyNightly, pypy37, {py37,py38,py39,py310,py311,pyNightly,pypy37}-no-ext, lint, check, security, docs, type-checking [testenv] usedevelop = true setenv = - {py37,py38,py39,py310,pyNightly}-no-ext: SANIC_NO_UJSON=1 - {py37,py38,py39,py310,pyNightly}-no-ext: SANIC_NO_UVLOOP=1 + {py37,py38,py39,py310,py311,pyNightly}-no-ext: SANIC_NO_UJSON=1 + {py37,py38,py39,py310,py311,pyNightly}-no-ext: SANIC_NO_UVLOOP=1 extras = test, http3 deps = httpx==0.23