11import os
22import datetime
33import asyncio
4+ import inspect
45from unittest import mock
56
67import httpx
910
1011import sentry_sdk
1112from sentry_sdk import capture_message , start_transaction
12- from sentry_sdk ._compat import iscoroutinefunction
1313from sentry_sdk .consts import MATCH_ALL , SPANDATA
1414from sentry_sdk .integrations .httpx import HttpxIntegration
1515from tests .conftest import ApproxDict
@@ -33,7 +33,7 @@ def before_breadcrumb(crumb, hint):
3333 with start_transaction ():
3434 events = capture_events ()
3535
36- if iscoroutinefunction (httpx_client .get ):
36+ if inspect . iscoroutinefunction (httpx_client .get ):
3737 response = asyncio .get_event_loop ().run_until_complete (
3838 httpx_client .get (url )
3939 )
@@ -87,7 +87,7 @@ def test_crumb_capture_client_error(
8787 with start_transaction ():
8888 events = capture_events ()
8989
90- if iscoroutinefunction (httpx_client .get ):
90+ if inspect . iscoroutinefunction (httpx_client .get ):
9191 response = asyncio .get_event_loop ().run_until_complete (
9292 httpx_client .get (url )
9393 )
@@ -138,7 +138,7 @@ def test_outgoing_trace_headers(sentry_init, httpx_client, httpx_mock):
138138 op = "greeting.sniff" ,
139139 trace_id = "01234567890123456789012345678901" ,
140140 ) as transaction :
141- if iscoroutinefunction (httpx_client .get ):
141+ if inspect . iscoroutinefunction (httpx_client .get ):
142142 response = asyncio .get_event_loop ().run_until_complete (
143143 httpx_client .get (url )
144144 )
@@ -181,7 +181,7 @@ def test_outgoing_trace_headers_append_to_baggage(
181181 op = "greeting.sniff" ,
182182 trace_id = "01234567890123456789012345678901" ,
183183 ) as transaction :
184- if iscoroutinefunction (httpx_client .get ):
184+ if inspect . iscoroutinefunction (httpx_client .get ):
185185 response = asyncio .get_event_loop ().run_until_complete (
186186 httpx_client .get (url , headers = {"baGGage" : "custom=data" })
187187 )
@@ -334,7 +334,7 @@ def test_option_trace_propagation_targets(
334334
335335 # Must be in a transaction to propagate headers
336336 with sentry_sdk .start_transaction ():
337- if iscoroutinefunction (httpx_client .get ):
337+ if inspect . iscoroutinefunction (httpx_client .get ):
338338 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
339339 else :
340340 httpx_client .get (url )
@@ -421,7 +421,7 @@ def test_request_source_disabled(
421421 url = "http://example.com/"
422422
423423 with start_transaction (name = "test_transaction" ):
424- if iscoroutinefunction (httpx_client .get ):
424+ if inspect . iscoroutinefunction (httpx_client .get ):
425425 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
426426 else :
427427 httpx_client .get (url )
@@ -458,7 +458,7 @@ def test_request_source_enabled(sentry_init, capture_events, httpx_client, httpx
458458 url = "http://example.com/"
459459
460460 with start_transaction (name = "test_transaction" ):
461- if iscoroutinefunction (httpx_client .get ):
461+ if inspect . iscoroutinefunction (httpx_client .get ):
462462 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
463463 else :
464464 httpx_client .get (url )
@@ -495,7 +495,7 @@ def test_request_source(sentry_init, capture_events, httpx_client, httpx_mock):
495495 url = "http://example.com/"
496496
497497 with start_transaction (name = "test_transaction" ):
498- if iscoroutinefunction (httpx_client .get ):
498+ if inspect . iscoroutinefunction (httpx_client .get ):
499499 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
500500 else :
501501 httpx_client .get (url )
@@ -548,7 +548,7 @@ def test_request_source_with_module_in_search_path(
548548 url = "http://example.com/"
549549
550550 with start_transaction (name = "test_transaction" ):
551- if iscoroutinefunction (httpx_client .get ):
551+ if inspect . iscoroutinefunction (httpx_client .get ):
552552 from httpx_helpers .helpers import async_get_request_with_client
553553
554554 asyncio .get_event_loop ().run_until_complete (
@@ -579,7 +579,7 @@ def test_request_source_with_module_in_search_path(
579579 is_relative_path = data .get (SPANDATA .CODE_FILEPATH )[0 ] != os .sep
580580 assert is_relative_path
581581
582- if iscoroutinefunction (httpx_client .get ):
582+ if inspect . iscoroutinefunction (httpx_client .get ):
583583 assert data .get (SPANDATA .CODE_FUNCTION ) == "async_get_request_with_client"
584584 else :
585585 assert data .get (SPANDATA .CODE_FUNCTION ) == "get_request_with_client"
@@ -619,7 +619,7 @@ def fake_start_span(*args, **kwargs):
619619 "sentry_sdk.integrations.httpx.start_span" ,
620620 fake_start_span ,
621621 ):
622- if iscoroutinefunction (httpx_client .get ):
622+ if inspect . iscoroutinefunction (httpx_client .get ):
623623 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
624624 else :
625625 httpx_client .get (url )
@@ -671,7 +671,7 @@ def fake_start_span(*args, **kwargs):
671671 "sentry_sdk.integrations.httpx.start_span" ,
672672 fake_start_span ,
673673 ):
674- if iscoroutinefunction (httpx_client .get ):
674+ if inspect . iscoroutinefunction (httpx_client .get ):
675675 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
676676 else :
677677 httpx_client .get (url )
@@ -721,7 +721,7 @@ def test_span_origin(sentry_init, capture_events, httpx_client, httpx_mock):
721721 url = "http://example.com/"
722722
723723 with start_transaction (name = "test_transaction" ):
724- if iscoroutinefunction (httpx_client .get ):
724+ if inspect . iscoroutinefunction (httpx_client .get ):
725725 asyncio .get_event_loop ().run_until_complete (httpx_client .get (url ))
726726 else :
727727 httpx_client .get (url )
0 commit comments