99
1010import sentry_sdk
1111from sentry_sdk import capture_message , start_transaction
12+ from sentry_sdk ._compat import iscoroutinefunction
1213from sentry_sdk .consts import MATCH_ALL , SPANDATA
1314from sentry_sdk .integrations .httpx import HttpxIntegration
1415from tests .conftest import ApproxDict
@@ -32,7 +33,7 @@ def before_breadcrumb(crumb, hint):
3233 with start_transaction ():
3334 events = capture_events ()
3435
35- if asyncio . iscoroutinefunction (httpx_client .get ):
36+ if iscoroutinefunction (httpx_client .get ):
3637 response = asyncio .get_event_loop ().run_until_complete (
3738 httpx_client .get (url )
3839 )
@@ -86,7 +87,7 @@ def test_crumb_capture_client_error(
8687 with start_transaction ():
8788 events = capture_events ()
8889
89- if asyncio . iscoroutinefunction (httpx_client .get ):
90+ if iscoroutinefunction (httpx_client .get ):
9091 response = asyncio .get_event_loop ().run_until_complete (
9192 httpx_client .get (url )
9293 )
@@ -137,7 +138,7 @@ def test_outgoing_trace_headers(sentry_init, httpx_client, httpx_mock):
137138 op = "greeting.sniff" ,
138139 trace_id = "01234567890123456789012345678901" ,
139140 ) as transaction :
140- if asyncio . iscoroutinefunction (httpx_client .get ):
141+ if iscoroutinefunction (httpx_client .get ):
141142 response = asyncio .get_event_loop ().run_until_complete (
142143 httpx_client .get (url )
143144 )
@@ -180,7 +181,7 @@ def test_outgoing_trace_headers_append_to_baggage(
180181 op = "greeting.sniff" ,
181182 trace_id = "01234567890123456789012345678901" ,
182183 ) as transaction :
183- if asyncio . iscoroutinefunction (httpx_client .get ):
184+ if iscoroutinefunction (httpx_client .get ):
184185 response = asyncio .get_event_loop ().run_until_complete (
185186 httpx_client .get (url , headers = {"baGGage" : "custom=data" })
186187 )
@@ -333,7 +334,7 @@ def test_option_trace_propagation_targets(
333334
334335 # Must be in a transaction to propagate headers
335336 with sentry_sdk .start_transaction ():
336- if asyncio . iscoroutinefunction (httpx_client .get ):
337+ if iscoroutinefunction (httpx_client .get ):
337338 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
338339 else :
339340 httpx_client .get (url )
@@ -420,7 +421,7 @@ def test_request_source_disabled(
420421 url = "http://example.com/"
421422
422423 with start_transaction (name = "test_transaction" ):
423- if asyncio . iscoroutinefunction (httpx_client .get ):
424+ if iscoroutinefunction (httpx_client .get ):
424425 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
425426 else :
426427 httpx_client .get (url )
@@ -457,7 +458,7 @@ def test_request_source_enabled(sentry_init, capture_events, httpx_client, httpx
457458 url = "http://example.com/"
458459
459460 with start_transaction (name = "test_transaction" ):
460- if asyncio . iscoroutinefunction (httpx_client .get ):
461+ if iscoroutinefunction (httpx_client .get ):
461462 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
462463 else :
463464 httpx_client .get (url )
@@ -494,7 +495,7 @@ def test_request_source(sentry_init, capture_events, httpx_client, httpx_mock):
494495 url = "http://example.com/"
495496
496497 with start_transaction (name = "test_transaction" ):
497- if asyncio . iscoroutinefunction (httpx_client .get ):
498+ if iscoroutinefunction (httpx_client .get ):
498499 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
499500 else :
500501 httpx_client .get (url )
@@ -547,7 +548,7 @@ def test_request_source_with_module_in_search_path(
547548 url = "http://example.com/"
548549
549550 with start_transaction (name = "test_transaction" ):
550- if asyncio . iscoroutinefunction (httpx_client .get ):
551+ if iscoroutinefunction (httpx_client .get ):
551552 from httpx_helpers .helpers import async_get_request_with_client
552553
553554 asyncio .get_event_loop ().run_until_complete (
@@ -578,7 +579,7 @@ def test_request_source_with_module_in_search_path(
578579 is_relative_path = data .get (SPANDATA .CODE_FILEPATH )[0 ] != os .sep
579580 assert is_relative_path
580581
581- if asyncio . iscoroutinefunction (httpx_client .get ):
582+ if iscoroutinefunction (httpx_client .get ):
582583 assert data .get (SPANDATA .CODE_FUNCTION ) == "async_get_request_with_client"
583584 else :
584585 assert data .get (SPANDATA .CODE_FUNCTION ) == "get_request_with_client"
@@ -618,7 +619,7 @@ def fake_start_span(*args, **kwargs):
618619 "sentry_sdk.integrations.httpx.start_span" ,
619620 fake_start_span ,
620621 ):
621- if asyncio . iscoroutinefunction (httpx_client .get ):
622+ if iscoroutinefunction (httpx_client .get ):
622623 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
623624 else :
624625 httpx_client .get (url )
@@ -670,7 +671,7 @@ def fake_start_span(*args, **kwargs):
670671 "sentry_sdk.integrations.httpx.start_span" ,
671672 fake_start_span ,
672673 ):
673- if asyncio . iscoroutinefunction (httpx_client .get ):
674+ if iscoroutinefunction (httpx_client .get ):
674675 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
675676 else :
676677 httpx_client .get (url )
@@ -720,7 +721,7 @@ def test_span_origin(sentry_init, capture_events, httpx_client, httpx_mock):
720721 url = "http://example.com/"
721722
722723 with start_transaction (name = "test_transaction" ):
723- if asyncio . iscoroutinefunction (httpx_client .get ):
724+ if iscoroutinefunction (httpx_client .get ):
724725 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
725726 else :
726727 httpx_client .get (url )
0 commit comments