From 10f96a73d2a7f2e46ea2a0b10d0bb0109eedf100 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Fri, 17 Jan 2025 15:17:27 +0100 Subject: [PATCH] trying something with httpx --- scripts/populate_tox/requirements.txt | 1 + tests/integrations/httpx/test_httpx.py | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/populate_tox/requirements.txt b/scripts/populate_tox/requirements.txt index 0402fac5ab..5233482b3f 100644 --- a/scripts/populate_tox/requirements.txt +++ b/scripts/populate_tox/requirements.txt @@ -1,3 +1,4 @@ jinja2 packaging requests +sentry_sdk diff --git a/tests/integrations/httpx/test_httpx.py b/tests/integrations/httpx/test_httpx.py index 17bf7017a5..d48ea120ae 100644 --- a/tests/integrations/httpx/test_httpx.py +++ b/tests/integrations/httpx/test_httpx.py @@ -12,6 +12,9 @@ from tests.conftest import ApproxDict +timeout = httpx.Timeout(10.0, read_timeout=None) + + @pytest.mark.parametrize( "httpx_client", (httpx.Client(), httpx.AsyncClient()), @@ -31,7 +34,7 @@ def before_breadcrumb(crumb, hint): if asyncio.iscoroutinefunction(httpx_client.get): response = asyncio.get_event_loop().run_until_complete( - httpx_client.get(url) + httpx_client.get(url, timeout=timeout, verify=False) ) else: response = httpx_client.get(url) @@ -74,7 +77,7 @@ def test_outgoing_trace_headers(sentry_init, httpx_client): ) as transaction: if asyncio.iscoroutinefunction(httpx_client.get): response = asyncio.get_event_loop().run_until_complete( - httpx_client.get(url) + httpx_client.get(url, timeout=timeout, verify=False) ) else: response = httpx_client.get(url) @@ -110,7 +113,12 @@ def test_outgoing_trace_headers_append_to_baggage(sentry_init, httpx_client): ) as transaction: if asyncio.iscoroutinefunction(httpx_client.get): response = asyncio.get_event_loop().run_until_complete( - httpx_client.get(url, headers={"baGGage": "custom=data"}) + httpx_client.get( + url, + headers={"baGGage": "custom=data"}, + timeout=timeout, + verify=False, + ) ) else: response = httpx_client.get(url, headers={"baGGage": "custom=data"}) @@ -261,7 +269,9 @@ def test_option_trace_propagation_targets( with sentry_sdk.start_transaction(): # Must be in a transaction to propagate headers if asyncio.iscoroutinefunction(httpx_client.get): - asyncio.get_event_loop().run_until_complete(httpx_client.get(url)) + asyncio.get_event_loop().run_until_complete( + httpx_client.get(url, timeout=timeout, verify=False) + ) else: httpx_client.get(url) @@ -339,7 +349,9 @@ def test_span_origin(sentry_init, capture_events, httpx_client): with start_transaction(name="test_transaction"): if asyncio.iscoroutinefunction(httpx_client.get): - asyncio.get_event_loop().run_until_complete(httpx_client.get(url)) + asyncio.get_event_loop().run_until_complete( + httpx_client.get(url, timeout=timeout, verify=False) + ) else: httpx_client.get(url)