Skip to content

Commit 2c3776c

Browse files
authored
tests: Move aiohttp under toxgen (#4319)
Depends on #4323
1 parent 434e8af commit 2c3776c

File tree

5 files changed

+37
-37
lines changed

5 files changed

+37
-37
lines changed

scripts/populate_tox/config.py

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
# See scripts/populate_tox/README.md for more info on the format and examples.
77

88
TEST_SUITE_CONFIG = {
9+
"aiohttp": {
10+
"package": "aiohttp",
11+
"deps": {
12+
"*": ["pytest-aiohttp"],
13+
">=3.8": ["pytest-asyncio"],
14+
},
15+
"python": ">=3.7",
16+
},
917
"ariadne": {
1018
"package": "ariadne",
1119
"deps": {

scripts/populate_tox/populate_tox.py

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"potel",
6868
# Integrations that can be migrated -- we should eventually remove all
6969
# of these from the IGNORE list
70-
"aiohttp",
7170
"anthropic",
7271
"arq",
7372
"asyncpg",

scripts/populate_tox/tox.jinja

-13
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ envlist =
3636
# At a minimum, we should test against at least the lowest
3737
# and the latest supported version of a framework.
3838

39-
# AIOHTTP
40-
{py3.7}-aiohttp-v{3.4}
41-
{py3.7,py3.9,py3.11}-aiohttp-v{3.8}
42-
{py3.8,py3.12,py3.13}-aiohttp-latest
43-
4439
# Anthropic
4540
{py3.8,py3.11,py3.12}-anthropic-v{0.16,0.28,0.40}
4641
{py3.7,py3.11,py3.12}-anthropic-latest
@@ -184,14 +179,6 @@ deps =
184179
185180
# === Integrations ===
186181
187-
# AIOHTTP
188-
aiohttp-v3.4: aiohttp~=3.4.0
189-
aiohttp-v3.8: aiohttp~=3.8.0
190-
aiohttp-latest: aiohttp
191-
aiohttp: pytest-aiohttp
192-
aiohttp-v3.8: pytest-asyncio
193-
aiohttp-latest: pytest-asyncio
194-
195182
# Anthropic
196183
anthropic: pytest-asyncio
197184
anthropic-v{0.16,0.28}: httpx<0.28.0

tests/integrations/aiohttp/test_aiohttp.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import asyncio
22
import json
3-
import sys
3+
44
from contextlib import suppress
55
from unittest import mock
66

77
import pytest
8+
9+
try:
10+
import pytest_asyncio
11+
except ImportError:
12+
pytest_asyncio = None
13+
814
from aiohttp import web, ClientSession
915
from aiohttp.client import ServerDisconnectedError
1016
from aiohttp.web_request import Request
@@ -21,6 +27,14 @@
2127
from tests.conftest import ApproxDict
2228

2329

30+
if pytest_asyncio is None:
31+
# `loop` was deprecated in `pytest-aiohttp`
32+
# in favor of `event_loop` from `pytest-asyncio`
33+
@pytest.fixture
34+
def event_loop(loop):
35+
yield loop
36+
37+
2438
@pytest.mark.asyncio
2539
async def test_basic(sentry_init, aiohttp_client, capture_events):
2640
sentry_init(integrations=[AioHttpIntegration()])
@@ -474,14 +488,6 @@ async def hello(request):
474488
assert error_event["contexts"]["trace"]["trace_id"] == trace_id
475489

476490

477-
if sys.version_info < (3, 12):
478-
# `loop` was deprecated in `pytest-aiohttp`
479-
# in favor of `event_loop` from `pytest-asyncio`
480-
@pytest.fixture
481-
def event_loop(loop):
482-
yield loop
483-
484-
485491
@pytest.mark.asyncio
486492
async def test_crumb_capture(
487493
sentry_init, aiohttp_raw_server, aiohttp_client, event_loop, capture_events

tox.ini

+14-14
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# The file (and all resulting CI YAMLs) then need to be regenerated via
1111
# "scripts/generate-test-files.sh".
1212
#
13-
# Last generated: 2025-04-23T07:46:44.042662+00:00
13+
# Last generated: 2025-04-23T08:07:00.653648+00:00
1414

1515
[tox]
1616
requires =
@@ -36,11 +36,6 @@ envlist =
3636
# At a minimum, we should test against at least the lowest
3737
# and the latest supported version of a framework.
3838

39-
# AIOHTTP
40-
{py3.7}-aiohttp-v{3.4}
41-
{py3.7,py3.9,py3.11}-aiohttp-v{3.8}
42-
{py3.8,py3.12,py3.13}-aiohttp-latest
43-
4439
# Anthropic
4540
{py3.8,py3.11,py3.12}-anthropic-v{0.16,0.28,0.40}
4641
{py3.7,py3.11,py3.12}-anthropic-latest
@@ -263,6 +258,11 @@ envlist =
263258

264259

265260
# ~~~ Web 2 ~~~
261+
{py3.7}-aiohttp-v3.4.4
262+
{py3.7}-aiohttp-v3.6.3
263+
{py3.7,py3.9,py3.10}-aiohttp-v3.8.6
264+
{py3.9,py3.12,py3.13}-aiohttp-v3.11.18
265+
266266
{py3.6,py3.7}-bottle-v0.12.25
267267
{py3.8,py3.12,py3.13}-bottle-v0.13.3
268268

@@ -335,14 +335,6 @@ deps =
335335

336336
# === Integrations ===
337337

338-
# AIOHTTP
339-
aiohttp-v3.4: aiohttp~=3.4.0
340-
aiohttp-v3.8: aiohttp~=3.8.0
341-
aiohttp-latest: aiohttp
342-
aiohttp: pytest-aiohttp
343-
aiohttp-v3.8: pytest-asyncio
344-
aiohttp-latest: pytest-asyncio
345-
346338
# Anthropic
347339
anthropic: pytest-asyncio
348340
anthropic-v{0.16,0.28}: httpx<0.28.0
@@ -699,6 +691,14 @@ deps =
699691

700692

701693
# ~~~ Web 2 ~~~
694+
aiohttp-v3.4.4: aiohttp==3.4.4
695+
aiohttp-v3.6.3: aiohttp==3.6.3
696+
aiohttp-v3.8.6: aiohttp==3.8.6
697+
aiohttp-v3.11.18: aiohttp==3.11.18
698+
aiohttp: pytest-aiohttp
699+
aiohttp-v3.8.6: pytest-asyncio
700+
aiohttp-v3.11.18: pytest-asyncio
701+
702702
bottle-v0.12.25: bottle==0.12.25
703703
bottle-v0.13.3: bottle==0.13.3
704704
bottle: werkzeug<2.1.0

0 commit comments

Comments
 (0)