Skip to content

Commit 236f70c

Browse files
webknjazbdraco
andcommitted
Re-introduce pytest-xdist in supported envs (#5431)
Co-authored-by: J. Nick Koston <[email protected]> (cherry picked from commit 751c3c4)
1 parent 1986b0a commit 236f70c

File tree

9 files changed

+214
-43
lines changed

9 files changed

+214
-43
lines changed

.github/workflows/ci-cd.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,15 @@ jobs:
206206
COLOR: yes
207207
AIOHTTP_NO_EXTENSIONS: ${{ matrix.no-extensions }}
208208
run: >- # `exit 1` makes sure that the job remains red with flaky runs
209-
pytest --no-cov -vvvvv --lf && exit 1
209+
pytest --no-cov --numprocesses=0 -vvvvv --lf && exit 1
210210
shell: bash
211211
- name: Run dev_mode tests
212212
env:
213213
COLOR: yes
214214
AIOHTTP_NO_EXTENSIONS: ${{ matrix.no-extensions }}
215215
PIP_USER: 1
216-
run: python -X dev -m pytest -m dev_mode --cov-append
216+
PYTHONDEVMODE: 1
217+
run: pytest -m dev_mode --cov-append --numprocesses=0
217218
shell: bash
218219
- name: Turn coverage into xml
219220
env:
@@ -278,7 +279,7 @@ jobs:
278279
uses: CodSpeedHQ/action@v3
279280
with:
280281
token: ${{ secrets.CODSPEED_TOKEN }}
281-
run: python -Im pytest --no-cov -vvvvv --codspeed
282+
run: python -Im pytest --no-cov --numprocesses=0 -vvvvv --codspeed
282283

283284

284285
check: # This job does nothing and is only used for the branch protection

requirements/constraints.txt

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#
2-
# This file is autogenerated by pip-compile with python 3.8
3-
# To update, run:
2+
# This file is autogenerated by pip-compile with Python 3.8
3+
# by the following command:
44
#
5-
# pip-compile --allow-unsafe --output-file=requirements/constraints.txt --resolver=backtracking --strip-extras requirements/constraints.in
5+
# pip-compile --allow-unsafe --output-file=requirements/constraints.txt --strip-extras requirements/constraints.in
66
#
77
aiodns==3.2.0 ; sys_platform == "linux" or sys_platform == "darwin"
88
# via
@@ -38,10 +38,11 @@ build==1.0.3
3838
# via pip-tools
3939
certifi==2023.7.22
4040
# via requests
41-
cffi==1.17.0
41+
cffi==1.17.1
4242
# via
4343
# cryptography
4444
# pycares
45+
# pytest-codspeed
4546
cfgv==3.3.1
4647
# via pre-commit
4748
charset-normalizer==3.2.0
@@ -72,10 +73,16 @@ docutils==0.20.1
7273
# via sphinx
7374
exceptiongroup==1.1.2
7475
# via pytest
75-
filelock==3.3.2
76-
# via virtualenv
76+
execnet==2.1.1
77+
# via pytest-xdist
78+
filelock==3.16.1
79+
# via
80+
# pytest-codspeed
81+
# virtualenv
7782
freezegun==1.5.1
78-
# via -r requirements/test.in
83+
# via
84+
# -r requirements/lint.in
85+
# -r requirements/test.in
7986
frozenlist==1.4.1
8087
# via
8188
# -r requirements/runtime-deps.in
@@ -170,11 +177,21 @@ pytest==8.3.2
170177
# via
171178
# -r requirements/lint.in
172179
# -r requirements/test.in
180+
# pytest-codspeed
173181
# pytest-cov
174182
# pytest-mock
183+
# pytest-xdist
184+
pytest-codspeed==2.2.1
185+
# via
186+
# -r requirements/lint.in
187+
# -r requirements/test.in
175188
pytest-cov==5.0.0
176189
# via -r requirements/test.in
177190
pytest-mock==3.14.0
191+
# via
192+
# -r requirements/lint.in
193+
# -r requirements/test.in
194+
pytest-xdist==3.6.1
178195
# via -r requirements/test.in
179196
python-dateutil==2.8.2
180197
# via freezegun
@@ -247,7 +264,9 @@ towncrier==23.11.0
247264
tqdm==4.62.3
248265
# via python-on-whales
249266
trustme==1.1.0 ; platform_machine != "i686"
250-
# via -r requirements/test.in
267+
# via
268+
# -r requirements/lint.in
269+
# -r requirements/test.in
251270
typer==0.6.1
252271
# via python-on-whales
253272
typing-extensions==4.12.2

requirements/test.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
coverage
55
freezegun
66
mypy; implementation_name == "cpython"
7-
proxy.py >= 2.4.4rc4
7+
proxy.py >= 2.4.4rc5
88
pytest
99
pytest-cov
1010
pytest-mock
11+
pytest-xdist
1112
pytest_codspeed
1213
python-on-whales
1314
re-assert

requirements/test.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#
2-
# This file is autogenerated by pip-compile with python 3.8
2+
# This file is autogenerated by pip-compile with Python 3.8
33
# by the following command:
44
#
5-
# pip-compile --allow-unsafe --output-file=requirements/test.txt --resolver=backtracking --strip-extras requirements/test.in
5+
# pip-compile --allow-unsafe --output-file=requirements/test.txt --strip-extras requirements/test.in
66
#
77
aiodns==3.2.0 ; sys_platform == "linux" or sys_platform == "darwin"
88
# via -r requirements/runtime-deps.in
@@ -39,6 +39,8 @@ cryptography==41.0.2
3939
# via trustme
4040
exceptiongroup==1.1.2
4141
# via pytest
42+
execnet==2.1.1
43+
# via pytest-xdist
4244
filelock==3.16.1
4345
# via pytest-codspeed
4446
freezegun==1.5.1
@@ -86,12 +88,15 @@ pytest==8.3.2
8688
# pytest-codspeed
8789
# pytest-cov
8890
# pytest-mock
91+
# pytest-xdist
8992
pytest-codspeed==2.2.1
9093
# via -r requirements/test.in
9194
pytest-cov==5.0.0
9295
# via -r requirements/test.in
9396
pytest-mock==3.14.0
9497
# via -r requirements/test.in
98+
pytest-xdist==3.6.1
99+
# via -r requirements/test.in
95100
python-dateutil==2.8.2
96101
# via freezegun
97102
python-on-whales==0.72.0

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ exclude_lines =
118118

119119
[tool:pytest]
120120
addopts =
121+
# `pytest-xdist`:
122+
--numprocesses=auto
123+
121124
# show 10 slowest invocations:
122125
--durations=10
123126

tests/test_client_request.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -751,14 +751,15 @@ async def test_urlencoded_formdata_charset(loop, conn) -> None:
751751
data=aiohttp.FormData({"hey": "you"}, charset="koi8-r"),
752752
loop=loop,
753753
)
754-
await req.send(conn)
754+
async with await req.send(conn):
755+
await asyncio.sleep(0)
755756
assert "application/x-www-form-urlencoded; charset=koi8-r" == req.headers.get(
756757
"CONTENT-TYPE"
757758
)
758759
await req.close()
759760

760761

761-
async def test_post_data(loop, conn) -> None:
762+
async def test_post_data(loop: asyncio.AbstractEventLoop, conn: mock.Mock) -> None:
762763
for meth in ClientRequest.POST_METHODS:
763764
req = ClientRequest(
764765
meth, URL("http://python.org/"), data={"life": "42"}, loop=loop
@@ -1087,10 +1088,12 @@ async def throw_exc():
10871088

10881089
loop.create_task(throw_exc())
10891090

1090-
await req.send(conn)
1091-
await req._writer
1092-
# assert conn.close.called
1093-
assert conn.protocol.set_exception.called
1091+
async with await req.send(conn):
1092+
assert req._writer is not None
1093+
await req._writer
1094+
# assert conn.close.called
1095+
assert conn.protocol is not None
1096+
assert conn.protocol.set_exception.called
10941097
await req.close()
10951098

10961099

@@ -1112,9 +1115,10 @@ async def throw_exc():
11121115

11131116
loop.create_task(throw_exc())
11141117

1115-
await req.send(conn)
1116-
await req._writer
1117-
# assert connection.close.called
1118+
async with await req.send(conn):
1119+
assert req._writer is not None
1120+
await req._writer
1121+
# assert conn.close.called
11181122
assert conn.protocol.set_exception.called
11191123
outer_exc = conn.protocol.set_exception.call_args[0][0]
11201124
assert isinstance(outer_exc, ClientConnectionError)

0 commit comments

Comments
 (0)