Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-introduce pytest-xdist in supported envs #5431

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,15 @@ jobs:
COLOR: yes
AIOHTTP_NO_EXTENSIONS: ${{ matrix.no-extensions }}
run: >- # `exit 1` makes sure that the job remains red with flaky runs
pytest --no-cov -vvvvv --lf && exit 1
pytest --no-cov --numprocesses=0 -vvvvv --lf && exit 1
shell: bash
- name: Run dev_mode tests
env:
COLOR: yes
AIOHTTP_NO_EXTENSIONS: ${{ matrix.no-extensions }}
PIP_USER: 1
run: python -X dev -m pytest -m dev_mode --cov-append
PYTHONDEVMODE: 1
run: pytest -m dev_mode --cov-append --numprocesses=0
shell: bash
- name: Turn coverage into xml
env:
Expand Down
9 changes: 9 additions & 0 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ aiosignal==1.3.1
# via -r requirements/runtime-deps.in
alabaster==0.7.13
# via sphinx
apipkg==1.5
# via execnet
async-timeout==4.0.3 ; python_version < "3.11"
# via
# -r requirements/runtime-deps.in
Expand Down Expand Up @@ -66,6 +68,8 @@ docutils==0.20.1
# via sphinx
exceptiongroup==1.1.2
# via pytest
execnet==2.1.1
# via pytest-xdist
filelock==3.12.2
# via virtualenv
freezegun==1.5.1
Expand Down Expand Up @@ -138,6 +142,8 @@ pre-commit==3.5.0
# via -r requirements/lint.in
proxy-py==2.4.4
# via -r requirements/test.in
py==1.11.0
# via pytest
pycares==4.3.0
# via aiodns
pycparser==2.21
Expand All @@ -162,10 +168,13 @@ pytest==8.1.1
# -r requirements/test.in
# pytest-cov
# pytest-mock
# pytest-xdist
pytest-cov==5.0.0
# via -r requirements/test.in
pytest-mock==3.14.0
# via -r requirements/test.in
pytest-xdist==3.6.1
# via -r requirements/test.txt
python-dateutil==2.8.2
# via freezegun
python-on-whales==0.71.0
Expand Down
3 changes: 2 additions & 1 deletion requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
coverage
freezegun
mypy; implementation_name == "cpython"
proxy.py >= 2.4.4rc4
proxy.py >= 2.4.4rc5
pytest
pytest-cov
pytest-mock
pytest-xdist
python-on-whales
re-assert
setuptools-git
Expand Down
7 changes: 7 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ cryptography==41.0.3
# via trustme
exceptiongroup==1.1.2
# via pytest
execnet==2.1.1
# via pytest-xdist
freezegun==1.5.1
# via -r requirements/test.in
frozenlist==1.4.1
Expand Down Expand Up @@ -65,6 +67,8 @@ pluggy==1.4.0
# via pytest
proxy-py==2.4.4
# via -r requirements/test.in
py==1.11.0
# via pytest
pycares==4.3.0
# via aiodns
pycparser==2.21
Expand All @@ -76,10 +80,13 @@ pytest==8.1.1
# -r requirements/test.in
# pytest-cov
# pytest-mock
# pytest-xdist
pytest-cov==5.0.0
# via -r requirements/test.in
pytest-mock==3.14.0
# via -r requirements/test.in
pytest-xdist==3.6.1
# via -r requirements/test.in
python-dateutil==2.8.2
# via freezegun
python-on-whales==0.71.0
Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ exclude_lines =

[tool:pytest]
addopts =
# `pytest-xdist`:
--numprocesses=auto
# ^ this is being added dynamically by tests._pytest_plugin instead
# Ref: https://github.com/pytest-dev/pytest-xdist/issues/620

# show 10 slowest invocations:
--durations=10

Expand All @@ -129,6 +134,7 @@ addopts =
--showlocals

# `pytest-cov`:
-p pytest_cov
--cov=aiohttp
--cov=tests/

Expand Down
27 changes: 16 additions & 11 deletions tests/test_client_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,18 +594,21 @@ async def test_connection_header(loop: Any, conn: Any) -> None:
req.keep_alive.return_value = True
req.version = HttpVersion(1, 1)
req.headers.clear()
await req.send(conn)
async with await req.send(conn):
await asyncio.sleep(0)
assert req.headers.get("CONNECTION") is None

req.version = HttpVersion(1, 0)
req.headers.clear()
await req.send(conn)
async with await req.send(conn):
await asyncio.sleep(0)
assert req.headers.get("CONNECTION") == "keep-alive"

req.keep_alive.return_value = False
req.version = HttpVersion(1, 1)
req.headers.clear()
await req.send(conn)
async with await req.send(conn):
await asyncio.sleep(0)
assert req.headers.get("CONNECTION") == "close"


Expand Down Expand Up @@ -698,7 +701,8 @@ async def test_urlencoded_formdata_charset(loop: Any, conn: Any) -> None:
data=aiohttp.FormData({"hey": "you"}, charset="koi8-r"),
loop=loop,
)
await req.send(conn)
async with await req.send(conn):
await asyncio.sleep(0)
assert "application/x-www-form-urlencoded; charset=koi8-r" == req.headers.get(
"CONTENT-TYPE"
)
Expand All @@ -715,7 +719,8 @@ async def test_formdata_boundary_from_headers(loop: Any, conn: Any) -> None:
headers={"Content-Type": f"multipart/form-data; boundary={boundary}"},
loop=loop,
)
await req.send(conn)
async with await req.send(conn):
await asyncio.sleep(0)
assert req.body._boundary == boundary.encode()


Expand Down Expand Up @@ -1028,10 +1033,10 @@ async def throw_exc():

loop.create_task(throw_exc())

await req.send(conn)
await req._writer
# assert conn.close.called
assert conn.protocol.set_exception.called
async with await req.send(conn):
await req._writer
# assert conn.close.called
assert conn.protocol.set_exception.called
await req.close()


Expand All @@ -1053,8 +1058,8 @@ async def throw_exc():

loop.create_task(throw_exc())

await req.send(conn)
await req._writer
async with await req.send(conn):
await req._writer
# assert connection.close.called
assert conn.protocol.set_exception.called
outer_exc = conn.protocol.set_exception.call_args[0][0]
Expand Down
Loading
Loading