Skip to content

tests: Move aiohttp under toxgen #4319

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

Merged
merged 10 commits into from
Apr 23, 2025
Merged
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
8 changes: 8 additions & 0 deletions scripts/populate_tox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
# See scripts/populate_tox/README.md for more info on the format and examples.

TEST_SUITE_CONFIG = {
"aiohttp": {
"package": "aiohttp",
"deps": {
"*": ["pytest-aiohttp"],
">=3.8": ["pytest-asyncio"],
},
"python": ">=3.7",
},
"ariadne": {
"package": "ariadne",
"deps": {
Expand Down
1 change: 0 additions & 1 deletion scripts/populate_tox/populate_tox.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"potel",
# Integrations that can be migrated -- we should eventually remove all
# of these from the IGNORE list
"aiohttp",
"anthropic",
"arq",
"asyncpg",
Expand Down
13 changes: 0 additions & 13 deletions scripts/populate_tox/tox.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ envlist =
# At a minimum, we should test against at least the lowest
# and the latest supported version of a framework.

# AIOHTTP
{py3.7}-aiohttp-v{3.4}
{py3.7,py3.9,py3.11}-aiohttp-v{3.8}
{py3.8,py3.12,py3.13}-aiohttp-latest

# Anthropic
{py3.8,py3.11,py3.12}-anthropic-v{0.16,0.28,0.40}
{py3.7,py3.11,py3.12}-anthropic-latest
Expand Down Expand Up @@ -184,14 +179,6 @@ deps =

# === Integrations ===

# AIOHTTP
aiohttp-v3.4: aiohttp~=3.4.0
aiohttp-v3.8: aiohttp~=3.8.0
aiohttp-latest: aiohttp
aiohttp: pytest-aiohttp
aiohttp-v3.8: pytest-asyncio
aiohttp-latest: pytest-asyncio

# Anthropic
anthropic: pytest-asyncio
anthropic-v{0.16,0.28}: httpx<0.28.0
Expand Down
24 changes: 15 additions & 9 deletions tests/integrations/aiohttp/test_aiohttp.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import asyncio
import json
import sys

from contextlib import suppress
from unittest import mock

import pytest

try:
import pytest_asyncio
except ImportError:
pytest_asyncio = None

from aiohttp import web, ClientSession
from aiohttp.client import ServerDisconnectedError
from aiohttp.web_request import Request
Expand All @@ -21,6 +27,14 @@
from tests.conftest import ApproxDict


if pytest_asyncio is None:
# `loop` was deprecated in `pytest-aiohttp`
# in favor of `event_loop` from `pytest-asyncio`
@pytest.fixture
def event_loop(loop):
yield loop


@pytest.mark.asyncio
async def test_basic(sentry_init, aiohttp_client, capture_events):
sentry_init(integrations=[AioHttpIntegration()])
Expand Down Expand Up @@ -474,14 +488,6 @@ async def hello(request):
assert error_event["contexts"]["trace"]["trace_id"] == trace_id


if sys.version_info < (3, 12):
# `loop` was deprecated in `pytest-aiohttp`
# in favor of `event_loop` from `pytest-asyncio`
@pytest.fixture
def event_loop(loop):
yield loop


@pytest.mark.asyncio
async def test_crumb_capture(
sentry_init, aiohttp_raw_server, aiohttp_client, event_loop, capture_events
Expand Down
28 changes: 14 additions & 14 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# The file (and all resulting CI YAMLs) then need to be regenerated via
# "scripts/generate-test-files.sh".
#
# Last generated: 2025-04-23T07:46:44.042662+00:00
# Last generated: 2025-04-23T08:07:00.653648+00:00

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

# AIOHTTP
{py3.7}-aiohttp-v{3.4}
{py3.7,py3.9,py3.11}-aiohttp-v{3.8}
{py3.8,py3.12,py3.13}-aiohttp-latest

# Anthropic
{py3.8,py3.11,py3.12}-anthropic-v{0.16,0.28,0.40}
{py3.7,py3.11,py3.12}-anthropic-latest
Expand Down Expand Up @@ -263,6 +258,11 @@ envlist =


# ~~~ Web 2 ~~~
{py3.7}-aiohttp-v3.4.4
{py3.7}-aiohttp-v3.6.3
{py3.7,py3.9,py3.10}-aiohttp-v3.8.6
{py3.9,py3.12,py3.13}-aiohttp-v3.11.18

{py3.6,py3.7}-bottle-v0.12.25
{py3.8,py3.12,py3.13}-bottle-v0.13.3

Expand Down Expand Up @@ -335,14 +335,6 @@ deps =

# === Integrations ===

# AIOHTTP
aiohttp-v3.4: aiohttp~=3.4.0
aiohttp-v3.8: aiohttp~=3.8.0
aiohttp-latest: aiohttp
aiohttp: pytest-aiohttp
aiohttp-v3.8: pytest-asyncio
aiohttp-latest: pytest-asyncio

# Anthropic
anthropic: pytest-asyncio
anthropic-v{0.16,0.28}: httpx<0.28.0
Expand Down Expand Up @@ -699,6 +691,14 @@ deps =


# ~~~ Web 2 ~~~
aiohttp-v3.4.4: aiohttp==3.4.4
aiohttp-v3.6.3: aiohttp==3.6.3
aiohttp-v3.8.6: aiohttp==3.8.6
aiohttp-v3.11.18: aiohttp==3.11.18
aiohttp: pytest-aiohttp
aiohttp-v3.8.6: pytest-asyncio
aiohttp-v3.11.18: pytest-asyncio

bottle-v0.12.25: bottle==0.12.25
bottle-v0.13.3: bottle==0.13.3
bottle: werkzeug<2.1.0
Expand Down
Loading