Move 3.11 tests to install aiohttp without C extensions (#3258)

* Move 311 tests to install aiohttp without C extensions

- Configure tox to install aiohttp without extensions
  - i.e. use `AIOHTTP_NO_EXTENSIONS=1` for pip install
  - This allows us to reenable blackd tests that use aiohttp testing helpers etc.
- Had to ignore `cgi` module deprecation warning
  - Filed issue for aiohttp to fix: https://github.com/aio-libs/aiohttp/issues/6905

Test:
- `/tmp/tb/bin/tox -e 311`

* Fix formatting + linting

* Add latest aiohttp for loop fix + Try to exempt deprecation warning but failed - will ask for help

* Remove unnecessary warning ignore

Co-authored-by: Cooper Ry Lees <me@wcooperlees.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
This commit is contained in:
Cooper Lees 2022-09-06 08:27:39 +10:00 committed by GitHub
parent 062e644aae
commit 383b228a16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 193 additions and 189 deletions

View File

@ -1,4 +1,4 @@
name: Partially test 3.11 dev name: Test 3.11 without aiohttp extensions
on: on:
push: push:

View File

@ -111,4 +111,7 @@ filterwarnings = [
# this is mitigated by https://github.com/python/cpython/issues/79071 in python 3.8+ # this is mitigated by https://github.com/python/cpython/issues/79071 in python 3.8+
# this ignore can be removed when support for 3.7 is dropped. # this ignore can be removed when support for 3.7 is dropped.
'''ignore:Bare functions are deprecated, use async ones:DeprecationWarning''', '''ignore:Bare functions are deprecated, use async ones:DeprecationWarning''',
# aiohttp is using deprecated cgi modules - Safe to remove when fixed:
# https://github.com/aio-libs/aiohttp/issues/6905
'''ignore:'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning''',
] ]

View File

@ -1,5 +1,4 @@
import re import re
import sys
from typing import TYPE_CHECKING, Any, Callable, TypeVar from typing import TYPE_CHECKING, Any, Callable, TypeVar
from unittest.mock import patch from unittest.mock import patch
@ -8,9 +7,6 @@
from tests.util import DETERMINISTIC_HEADER, read_data from tests.util import DETERMINISTIC_HEADER, read_data
LESS_THAN_311 = sys.version_info < (3, 11)
if LESS_THAN_311: # noqa: C901
try: try:
from aiohttp import web from aiohttp import web
from aiohttp.test_utils import AioHTTPTestCase from aiohttp.test_utils import AioHTTPTestCase
@ -33,6 +29,7 @@
def unittest_run_loop(func, *args, **kwargs): def unittest_run_loop(func, *args, **kwargs):
return func return func
@pytest.mark.blackd @pytest.mark.blackd
class BlackDTestCase(AioHTTPTestCase): # type: ignore[misc] class BlackDTestCase(AioHTTPTestCase): # type: ignore[misc]
def test_blackd_main(self) -> None: def test_blackd_main(self) -> None:

View File

@ -51,16 +51,20 @@ commands =
coverage report coverage report
[testenv:{,ci-}311] [testenv:{,ci-}311]
setenv = PYTHONPATH = {toxinidir}/src setenv =
PYTHONPATH = {toxinidir}/src
AIOHTTP_NO_EXTENSIONS = 1
skip_install = True skip_install = True
recreate = True recreate = True
deps = deps =
; We currently need > aiohttp 3.8.1 that is on PyPI for 3.11
git+https://github.com/aio-libs/aiohttp
-r{toxinidir}/test_requirements.txt -r{toxinidir}/test_requirements.txt
; a separate worker is required in ci due to https://foss.heptapod.net/pypy/pypy/-/issues/3317 ; a separate worker is required in ci due to https://foss.heptapod.net/pypy/pypy/-/issues/3317
; this seems to cause tox to wait forever ; this seems to cause tox to wait forever
; remove this when pypy releases the bugfix ; remove this when pypy releases the bugfix
commands = commands =
pip install -e . pip install -e .[d]
coverage erase coverage erase
pytest tests \ pytest tests \
--run-optional no_jupyter \ --run-optional no_jupyter \