Skip to content

Commit c1c6e0b

Browse files
authored
Remove remote example.com calls (#4622)
1 parent add8b6f commit c1c6e0b

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

tests/integrations/aiohttp/test_aiohttp.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88

9-
from aiohttp import web, ClientSession
9+
from aiohttp import web
1010
from aiohttp.client import ServerDisconnectedError
1111
from aiohttp.web_request import Request
1212
from aiohttp.web_exceptions import (
@@ -636,6 +636,7 @@ async def handler(request):
636636
@pytest.mark.asyncio
637637
async def test_span_origin(
638638
sentry_init,
639+
aiohttp_raw_server,
639640
aiohttp_client,
640641
capture_events,
641642
):
@@ -644,10 +645,16 @@ async def test_span_origin(
644645
traces_sample_rate=1.0,
645646
)
646647

648+
# server for making span request
649+
async def handler(request):
650+
return web.Response(text="OK")
651+
652+
raw_server = await aiohttp_raw_server(handler)
653+
647654
async def hello(request):
648-
async with ClientSession() as session:
649-
async with session.get("http://example.com"):
650-
return web.Response(text="hello")
655+
span_client = await aiohttp_client(raw_server)
656+
await span_client.get("/")
657+
return web.Response(text="hello")
651658

652659
app = web.Application()
653660
app.router.add_get(r"/", hello)

tests/integrations/stdlib/test_httplib.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def test_empty_realurl(sentry_init):
123123
"""
124124

125125
sentry_init(dsn="")
126-
HTTPConnection("example.com", port=443).putrequest("POST", None)
126+
HTTPConnection("localhost", port=PORT).putrequest("POST", None)
127127

128128

129129
def test_httplib_misuse(sentry_init, capture_events, request):
@@ -379,7 +379,7 @@ def test_span_origin(sentry_init, capture_events):
379379
events = capture_events()
380380

381381
with start_transaction(name="foo"):
382-
conn = HTTPConnection("example.com")
382+
conn = HTTPConnection("localhost", port=PORT)
383383
conn.request("GET", "/foo")
384384
conn.getresponse()
385385

@@ -400,7 +400,7 @@ def test_http_timeout(monkeypatch, sentry_init, capture_envelopes):
400400

401401
with pytest.raises(TimeoutError):
402402
with start_transaction(op="op", name="name"):
403-
conn = HTTPSConnection("www.example.com")
403+
conn = HTTPConnection("localhost", port=PORT)
404404
conn.request("GET", "/bla")
405405
conn.getresponse()
406406

@@ -410,4 +410,4 @@ def test_http_timeout(monkeypatch, sentry_init, capture_envelopes):
410410

411411
span = transaction["spans"][0]
412412
assert span["op"] == "http.client"
413-
assert span["description"] == "GET https://www.example.com/bla"
413+
assert span["description"] == f"GET http://localhost:{PORT}/bla" # noqa: E231

0 commit comments

Comments
 (0)