From f5f7ffe16bb655e743dc0604594d9538c65453c5 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 19 Mar 2025 12:08:43 +0100 Subject: [PATCH 1/2] Updated test, so hopefully it is not flaky anymore --- tests/integrations/stdlib/test_httplib.py | 25 ++++++++--------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/tests/integrations/stdlib/test_httplib.py b/tests/integrations/stdlib/test_httplib.py index 892e07980b..e67701c4dd 100644 --- a/tests/integrations/stdlib/test_httplib.py +++ b/tests/integrations/stdlib/test_httplib.py @@ -398,25 +398,16 @@ def test_http_timeout(monkeypatch, sentry_init, capture_envelopes): envelopes = capture_envelopes() - with start_transaction(op="op", name="name"): - try: - conn = HTTPSConnection("www.squirrelchasers.com") - conn.request("GET", "/top-chasers") + with pytest.raises(TimeoutError): + with start_transaction(op="op", name="name"): + conn = HTTPSConnection("www.example.com") + conn.request("GET", "/bla") conn.getresponse() - except Exception: - pass - - items = [ - item - for envelope in envelopes - for item in envelope.items - if item.type == "transaction" - ] - assert len(items) == 1 - - transaction = items[0].payload.json + + (transaction_envelope, ) = envelopes + transaction = transaction_envelope.get_transaction_event() assert len(transaction["spans"]) == 1 span = transaction["spans"][0] assert span["op"] == "http.client" - assert span["description"] == "GET https://www.squirrelchasers.com/top-chasers" + assert span["description"] == "GET https://www.example.com/bla" From 910f6831db37dd11e9d7870f45f339b98f1113e5 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 19 Mar 2025 12:21:42 +0100 Subject: [PATCH 2/2] linting --- tests/integrations/stdlib/test_httplib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integrations/stdlib/test_httplib.py b/tests/integrations/stdlib/test_httplib.py index e67701c4dd..908a22dc6c 100644 --- a/tests/integrations/stdlib/test_httplib.py +++ b/tests/integrations/stdlib/test_httplib.py @@ -404,7 +404,7 @@ def test_http_timeout(monkeypatch, sentry_init, capture_envelopes): conn.request("GET", "/bla") conn.getresponse() - (transaction_envelope, ) = envelopes + (transaction_envelope,) = envelopes transaction = transaction_envelope.get_transaction_event() assert len(transaction["spans"]) == 1