3
3
4
4
import httpx
5
5
import pytest
6
- import responses
7
6
8
7
import sentry_sdk
9
8
from sentry_sdk import capture_message , start_transaction
16
15
"httpx_client" ,
17
16
(httpx .Client (), httpx .AsyncClient ()),
18
17
)
19
- def test_crumb_capture_and_hint (sentry_init , capture_events , httpx_client ):
18
+ def test_crumb_capture_and_hint (sentry_init , capture_events , httpx_client , httpx_mock ):
19
+ httpx_mock .add_response ()
20
+
20
21
def before_breadcrumb (crumb , hint ):
21
22
crumb ["data" ]["extra" ] = "foo"
22
23
return crumb
23
24
24
25
sentry_init (integrations = [HttpxIntegration ()], before_breadcrumb = before_breadcrumb )
25
26
26
27
url = "http://example.com/"
27
- responses .add (responses .GET , url , status = 200 )
28
28
29
29
with start_transaction ():
30
30
events = capture_events ()
@@ -61,11 +61,15 @@ def before_breadcrumb(crumb, hint):
61
61
"httpx_client" ,
62
62
(httpx .Client (), httpx .AsyncClient ()),
63
63
)
64
- def test_outgoing_trace_headers (sentry_init , httpx_client ):
65
- sentry_init (traces_sample_rate = 1.0 , integrations = [HttpxIntegration ()])
64
+ def test_outgoing_trace_headers (sentry_init , httpx_client , httpx_mock ):
65
+ httpx_mock .add_response ()
66
+
67
+ sentry_init (
68
+ traces_sample_rate = 1.0 ,
69
+ integrations = [HttpxIntegration ()],
70
+ )
66
71
67
72
url = "http://example.com/"
68
- responses .add (responses .GET , url , status = 200 )
69
73
70
74
with start_transaction (
71
75
name = "/interactions/other-dogs/new-dog" ,
@@ -93,15 +97,20 @@ def test_outgoing_trace_headers(sentry_init, httpx_client):
93
97
"httpx_client" ,
94
98
(httpx .Client (), httpx .AsyncClient ()),
95
99
)
96
- def test_outgoing_trace_headers_append_to_baggage (sentry_init , httpx_client ):
100
+ def test_outgoing_trace_headers_append_to_baggage (
101
+ sentry_init ,
102
+ httpx_client ,
103
+ httpx_mock ,
104
+ ):
105
+ httpx_mock .add_response ()
106
+
97
107
sentry_init (
98
108
traces_sample_rate = 1.0 ,
99
109
integrations = [HttpxIntegration ()],
100
110
release = "d08ebdb9309e1b004c6f52202de58a09c2268e42" ,
101
111
)
102
112
103
113
url = "http://example.com/"
104
- responses .add (responses .GET , url , status = 200 )
105
114
106
115
with start_transaction (
107
116
name = "/interactions/other-dogs/new-dog" ,
@@ -290,12 +299,13 @@ def test_do_not_propagate_outside_transaction(sentry_init, httpx_mock):
290
299
291
300
292
301
@pytest .mark .tests_internal_exceptions
293
- def test_omit_url_data_if_parsing_fails (sentry_init , capture_events ):
302
+ def test_omit_url_data_if_parsing_fails (sentry_init , capture_events , httpx_mock ):
303
+ httpx_mock .add_response ()
304
+
294
305
sentry_init (integrations = [HttpxIntegration ()])
295
306
296
307
httpx_client = httpx .Client ()
297
308
url = "http://example.com"
298
- responses .add (responses .GET , url , status = 200 )
299
309
300
310
events = capture_events ()
301
311
with mock .patch (
@@ -326,7 +336,9 @@ def test_omit_url_data_if_parsing_fails(sentry_init, capture_events):
326
336
"httpx_client" ,
327
337
(httpx .Client (), httpx .AsyncClient ()),
328
338
)
329
- def test_span_origin (sentry_init , capture_events , httpx_client ):
339
+ def test_span_origin (sentry_init , capture_events , httpx_client , httpx_mock ):
340
+ httpx_mock .add_response ()
341
+
330
342
sentry_init (
331
343
integrations = [HttpxIntegration ()],
332
344
traces_sample_rate = 1.0 ,
@@ -335,7 +347,6 @@ def test_span_origin(sentry_init, capture_events, httpx_client):
335
347
events = capture_events ()
336
348
337
349
url = "http://example.com/"
338
- responses .add (responses .GET , url , status = 200 )
339
350
340
351
with start_transaction (name = "test_transaction" ):
341
352
if asyncio .iscoroutinefunction (httpx_client .get ):
0 commit comments