Skip to content

Commit 386d4ef

Browse files
committed
Merge branch 'master' into ivana/populate-tox-step-by-step
2 parents d6b4257 + 4ae94a5 commit 386d4ef

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

tests/integrations/httpx/test_httpx.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import httpx
55
import pytest
6-
import responses
76

87
import sentry_sdk
98
from sentry_sdk import capture_message, start_transaction
@@ -19,15 +18,16 @@
1918
"httpx_client",
2019
(httpx.Client(), httpx.AsyncClient()),
2120
)
22-
def test_crumb_capture_and_hint(sentry_init, capture_events, httpx_client):
21+
def test_crumb_capture_and_hint(sentry_init, capture_events, httpx_client, httpx_mock):
22+
httpx_mock.add_response()
23+
2324
def before_breadcrumb(crumb, hint):
2425
crumb["data"]["extra"] = "foo"
2526
return crumb
2627

2728
sentry_init(integrations=[HttpxIntegration()], before_breadcrumb=before_breadcrumb)
2829

2930
url = "http://example.com/"
30-
responses.add(responses.GET, url, status=200)
3131

3232
with start_transaction():
3333
events = capture_events()
@@ -67,11 +67,15 @@ def before_breadcrumb(crumb, hint):
6767
"httpx_client",
6868
(httpx.Client(), httpx.AsyncClient()),
6969
)
70-
def test_outgoing_trace_headers(sentry_init, httpx_client):
71-
sentry_init(traces_sample_rate=1.0, integrations=[HttpxIntegration()])
70+
def test_outgoing_trace_headers(sentry_init, httpx_client, httpx_mock):
71+
httpx_mock.add_response()
72+
73+
sentry_init(
74+
traces_sample_rate=1.0,
75+
integrations=[HttpxIntegration()],
76+
)
7277

7378
url = "http://example.com/"
74-
responses.add(responses.GET, url, status=200)
7579

7680
with start_transaction(
7781
name="/interactions/other-dogs/new-dog",
@@ -102,15 +106,20 @@ def test_outgoing_trace_headers(sentry_init, httpx_client):
102106
"httpx_client",
103107
(httpx.Client(), httpx.AsyncClient()),
104108
)
105-
def test_outgoing_trace_headers_append_to_baggage(sentry_init, httpx_client):
109+
def test_outgoing_trace_headers_append_to_baggage(
110+
sentry_init,
111+
httpx_client,
112+
httpx_mock,
113+
):
114+
httpx_mock.add_response()
115+
106116
sentry_init(
107117
traces_sample_rate=1.0,
108118
integrations=[HttpxIntegration()],
109119
release="d08ebdb9309e1b004c6f52202de58a09c2268e42",
110120
)
111121

112122
url = "http://example.com/"
113-
responses.add(responses.GET, url, status=200)
114123

115124
with start_transaction(
116125
name="/interactions/other-dogs/new-dog",
@@ -310,12 +319,13 @@ def test_do_not_propagate_outside_transaction(sentry_init, httpx_mock):
310319

311320

312321
@pytest.mark.tests_internal_exceptions
313-
def test_omit_url_data_if_parsing_fails(sentry_init, capture_events):
322+
def test_omit_url_data_if_parsing_fails(sentry_init, capture_events, httpx_mock):
323+
httpx_mock.add_response()
324+
314325
sentry_init(integrations=[HttpxIntegration()])
315326

316327
httpx_client = httpx.Client()
317328
url = "http://example.com"
318-
responses.add(responses.GET, url, status=200)
319329

320330
events = capture_events()
321331
with mock.patch(
@@ -346,7 +356,9 @@ def test_omit_url_data_if_parsing_fails(sentry_init, capture_events):
346356
"httpx_client",
347357
(httpx.Client(), httpx.AsyncClient()),
348358
)
349-
def test_span_origin(sentry_init, capture_events, httpx_client):
359+
def test_span_origin(sentry_init, capture_events, httpx_client, httpx_mock):
360+
httpx_mock.add_response()
361+
350362
sentry_init(
351363
integrations=[HttpxIntegration()],
352364
traces_sample_rate=1.0,
@@ -355,7 +367,6 @@ def test_span_origin(sentry_init, capture_events, httpx_client):
355367
events = capture_events()
356368

357369
url = "http://example.com/"
358-
responses.add(responses.GET, url, status=200)
359370

360371
with start_transaction(name="test_transaction"):
361372
if asyncio.iscoroutinefunction(httpx_client.get):

0 commit comments

Comments
 (0)