Skip to content

Commit 8482975

Browse files
bdracowebknjaz
andauthored
[PR #5431/751c3c4 backport][3.11] Re-introduce pytest-xdist in supported envs (#9747)
Co-authored-by: J. Nick Koston <[email protected]> Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
1 parent a59c96a commit 8482975

File tree

9 files changed

+213
-37
lines changed

9 files changed

+213
-37
lines changed

.github/workflows/ci-cd.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,15 @@ jobs:
204204
COLOR: yes
205205
AIOHTTP_NO_EXTENSIONS: ${{ matrix.no-extensions }}
206206
run: >- # `exit 1` makes sure that the job remains red with flaky runs
207-
pytest --no-cov -vvvvv --lf && exit 1
207+
pytest --no-cov --numprocesses=0 -vvvvv --lf && exit 1
208208
shell: bash
209209
- name: Run dev_mode tests
210210
env:
211211
COLOR: yes
212212
AIOHTTP_NO_EXTENSIONS: ${{ matrix.no-extensions }}
213213
PIP_USER: 1
214-
run: python -X dev -m pytest -m dev_mode --cov-append
214+
PYTHONDEVMODE: 1
215+
run: pytest -m dev_mode --cov-append --numprocesses=0
215216
shell: bash
216217
- name: Turn coverage into xml
217218
env:
@@ -276,7 +277,7 @@ jobs:
276277
uses: CodSpeedHQ/action@v3
277278
with:
278279
token: ${{ secrets.CODSPEED_TOKEN }}
279-
run: python -Im pytest --no-cov -vvvvv --codspeed
280+
run: python -Im pytest --no-cov --numprocesses=0 -vvvvv --codspeed
280281

281282

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

requirements/constraints.txt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ alabaster==0.7.13
1818
# via sphinx
1919
annotated-types==0.7.0
2020
# via pydantic
21+
apipkg==1.5
22+
# via execnet
2123
async-timeout==4.0.3 ; python_version < "3.11"
2224
# via
2325
# -r requirements/runtime-deps.in
@@ -71,6 +73,8 @@ filelock==3.16.1
7173
# via
7274
# pytest-codspeed
7375
# virtualenv
76+
execnet==2.1.1
77+
# via pytest-xdist
7478
freezegun==1.5.1
7579
# via
7680
# -r requirements/lint.in
@@ -144,7 +148,11 @@ propcache==0.2.0
144148
# -r requirements/runtime-deps.in
145149
# yarl
146150
proxy-py==2.4.9
147-
# via -r requirements/test.in
151+
# via
152+
# -r requirements/lint.in
153+
# -r requirements/test.in
154+
py==1.11.0
155+
# via pytest
148156
pycares==4.4.0
149157
# via aiodns
150158
pycparser==2.22
@@ -174,12 +182,25 @@ pytest==8.3.3
174182
# pytest-codspeed
175183
# pytest-cov
176184
# pytest-mock
185+
# pytest-xdist
177186
pytest-codspeed==3.0.0
178187
# via
179188
# -r requirements/lint.in
180189
# -r requirements/test.in
181190
pytest-cov==5.0.0
182191
# via -r requirements/test.in
192+
pytest-mock==3.14.0
193+
# via -r requirements/test.in
194+
pytest-xdist==3.6.1
195+
# via -r requirements/test.txt
196+
python-dateutil==2.8.2
197+
# via freezegun
198+
python-on-whales==0.71.0
199+
# via
200+
# -r requirements/lint.in
201+
# -r requirements/test.in
202+
pytest-cov==5.0.0
203+
# via -r requirements/test.in
183204
pytest-mock==3.14.0
184205
# via
185206
# -r requirements/lint.in

requirements/test.in

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

requirements/test.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ cryptography==43.0.3
3939
# via trustme
4040
exceptiongroup==1.2.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
@@ -80,6 +82,8 @@ propcache==0.2.0
8082
# yarl
8183
proxy-py==2.4.9
8284
# via -r requirements/test.in
85+
py==1.11.0
86+
# via pytest
8387
pycares==4.4.0
8488
# via aiodns
8589
pycparser==2.22
@@ -97,11 +101,15 @@ pytest==8.3.3
97101
# pytest-cov
98102
# pytest-mock
99103
pytest-codspeed==3.0.0
100-
# via -r requirements/test.in
104+
# via
105+
# -r requirements/test.in
106+
# pytest-xdist
101107
pytest-cov==5.0.0
102108
# via -r requirements/test.in
103109
pytest-mock==3.14.0
104110
# via -r requirements/test.in
111+
pytest-xdist==3.6.1
112+
# via -r requirements/test.in
105113
python-dateutil==2.9.0.post0
106114
# via freezegun
107115
python-on-whales==0.73.0

setup.cfg

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

126126
[tool:pytest]
127127
addopts =
128+
# `pytest-xdist`:
129+
--numprocesses=auto
130+
128131
# show 10 slowest invocations:
129132
--durations=10
130133

tests/test_client_request.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -744,14 +744,15 @@ async def test_urlencoded_formdata_charset(loop, conn) -> None:
744744
data=aiohttp.FormData({"hey": "you"}, charset="koi8-r"),
745745
loop=loop,
746746
)
747-
await req.send(conn)
747+
async with await req.send(conn):
748+
await asyncio.sleep(0)
748749
assert "application/x-www-form-urlencoded; charset=koi8-r" == req.headers.get(
749750
"CONTENT-TYPE"
750751
)
751752
await req.close()
752753

753754

754-
async def test_post_data(loop, conn) -> None:
755+
async def test_post_data(loop: asyncio.AbstractEventLoop, conn: mock.Mock) -> None:
755756
for meth in ClientRequest.POST_METHODS:
756757
req = ClientRequest(
757758
meth, URL("http://python.org/"), data={"life": "42"}, loop=loop
@@ -1080,10 +1081,12 @@ async def throw_exc():
10801081

10811082
loop.create_task(throw_exc())
10821083

1083-
await req.send(conn)
1084-
await req._writer
1085-
# assert conn.close.called
1086-
assert conn.protocol.set_exception.called
1084+
async with await req.send(conn):
1085+
assert req._writer is not None
1086+
await req._writer
1087+
# assert conn.close.called
1088+
assert conn.protocol is not None
1089+
assert conn.protocol.set_exception.called
10871090
await req.close()
10881091

10891092

@@ -1105,9 +1108,10 @@ async def throw_exc():
11051108

11061109
loop.create_task(throw_exc())
11071110

1108-
await req.send(conn)
1109-
await req._writer
1110-
# assert connection.close.called
1111+
async with await req.send(conn):
1112+
assert req._writer is not None
1113+
await req._writer
1114+
# assert conn.close.called
11111115
assert conn.protocol.set_exception.called
11121116
outer_exc = conn.protocol.set_exception.call_args[0][0]
11131117
assert isinstance(outer_exc, ClientConnectionError)

0 commit comments

Comments
 (0)