diff --git a/tests/integrations/aiohttp/test_aiohttp.py b/tests/integrations/aiohttp/test_aiohttp.py index 47152f254c..dbb4286370 100644 --- a/tests/integrations/aiohttp/test_aiohttp.py +++ b/tests/integrations/aiohttp/test_aiohttp.py @@ -6,7 +6,7 @@ import pytest -from aiohttp import web, ClientSession +from aiohttp import web from aiohttp.client import ServerDisconnectedError from aiohttp.web_request import Request from aiohttp.web_exceptions import ( @@ -636,6 +636,7 @@ async def handler(request): @pytest.mark.asyncio async def test_span_origin( sentry_init, + aiohttp_raw_server, aiohttp_client, capture_events, ): @@ -644,10 +645,16 @@ async def test_span_origin( traces_sample_rate=1.0, ) + # server for making span request + async def handler(request): + return web.Response(text="OK") + + raw_server = await aiohttp_raw_server(handler) + async def hello(request): - async with ClientSession() as session: - async with session.get("http://example.com"): - return web.Response(text="hello") + span_client = await aiohttp_client(raw_server) + await span_client.get("/") + return web.Response(text="hello") app = web.Application() app.router.add_get(r"/", hello) diff --git a/tests/integrations/stdlib/test_httplib.py b/tests/integrations/stdlib/test_httplib.py index 908a22dc6c..f6735d0e74 100644 --- a/tests/integrations/stdlib/test_httplib.py +++ b/tests/integrations/stdlib/test_httplib.py @@ -123,7 +123,7 @@ def test_empty_realurl(sentry_init): """ sentry_init(dsn="") - HTTPConnection("example.com", port=443).putrequest("POST", None) + HTTPConnection("localhost", port=PORT).putrequest("POST", None) def test_httplib_misuse(sentry_init, capture_events, request): @@ -379,7 +379,7 @@ def test_span_origin(sentry_init, capture_events): events = capture_events() with start_transaction(name="foo"): - conn = HTTPConnection("example.com") + conn = HTTPConnection("localhost", port=PORT) conn.request("GET", "/foo") conn.getresponse() @@ -400,7 +400,7 @@ def test_http_timeout(monkeypatch, sentry_init, capture_envelopes): with pytest.raises(TimeoutError): with start_transaction(op="op", name="name"): - conn = HTTPSConnection("www.example.com") + conn = HTTPConnection("localhost", port=PORT) conn.request("GET", "/bla") conn.getresponse() @@ -410,4 +410,4 @@ def test_http_timeout(monkeypatch, sentry_init, capture_envelopes): span = transaction["spans"][0] assert span["op"] == "http.client" - assert span["description"] == "GET https://www.example.com/bla" + assert span["description"] == f"GET http://localhost:{PORT}/bla" # noqa: E231