|
10 | 10 | from unittest import mock |
11 | 11 |
|
12 | 12 | import brotli |
| 13 | +import httpcore |
13 | 14 | import pytest |
14 | 15 | from pytest_localserver.http import WSGIServer |
15 | 16 | from werkzeug.wrappers import Request, Response |
@@ -282,6 +283,30 @@ def test_default_timeout(make_client): |
282 | 283 | assert options["timeout"].total == client.transport.TIMEOUT |
283 | 284 |
|
284 | 285 |
|
| 286 | +@pytest.mark.skipif(not PY38, reason="HTTP2 libraries are only available in py3.8+") |
| 287 | +def test_default_timeout_http2(make_client): |
| 288 | + client = make_client(_experiments={"transport_http2": True}) |
| 289 | + |
| 290 | + with mock.patch( |
| 291 | + "sentry_sdk.transport.httpcore.ConnectionPool.request", |
| 292 | + return_value=httpcore.Response(200), |
| 293 | + ) as request_mock: |
| 294 | + sentry_sdk.get_global_scope().set_client(client) |
| 295 | + capture_message("hi") |
| 296 | + client.flush() |
| 297 | + |
| 298 | + request_mock.assert_called_once() |
| 299 | + assert request_mock.call_args.kwargs["extensions"] == { |
| 300 | + "timeout": { |
| 301 | + "pool": client.transport.TIMEOUT, |
| 302 | + "connect": client.transport.TIMEOUT, |
| 303 | + "write": client.transport.TIMEOUT, |
| 304 | + "read": client.transport.TIMEOUT, |
| 305 | + } |
| 306 | + } |
| 307 | + sentry_sdk.get_global_scope().set_client(None) |
| 308 | + |
| 309 | + |
285 | 310 | @pytest.mark.skipif(not PY38, reason="HTTP2 libraries are only available in py3.8+") |
286 | 311 | def test_http2_with_https_dsn(make_client): |
287 | 312 | client = make_client(_experiments={"transport_http2": True}) |
|
0 commit comments