|
5 | 5 |
|
6 | 6 | import pytest |
7 | 7 |
|
| 8 | +import hyperbrowser.client.timeout_utils as timeout_helpers |
8 | 9 | from hyperbrowser import AsyncHyperbrowser, Hyperbrowser |
9 | 10 | from hyperbrowser.exceptions import HyperbrowserError |
10 | 11 |
|
@@ -130,3 +131,33 @@ def test_async_client_rejects_overflowing_real_timeout(): |
130 | 131 | AsyncHyperbrowser(api_key="test-key", timeout=Fraction(10**1000, 1)) |
131 | 132 |
|
132 | 133 | assert exc_info.value.original_error is not None |
| 134 | + |
| 135 | + |
| 136 | +def test_sync_client_wraps_timeout_isfinite_failures( |
| 137 | + monkeypatch: pytest.MonkeyPatch, |
| 138 | +): |
| 139 | + def _raise_isfinite_error(value: float) -> bool: |
| 140 | + _ = value |
| 141 | + raise OverflowError("finite check overflow") |
| 142 | + |
| 143 | + monkeypatch.setattr(timeout_helpers.math, "isfinite", _raise_isfinite_error) |
| 144 | + |
| 145 | + with pytest.raises(HyperbrowserError, match="timeout must be finite") as exc_info: |
| 146 | + Hyperbrowser(api_key="test-key", timeout=1) |
| 147 | + |
| 148 | + assert exc_info.value.original_error is not None |
| 149 | + |
| 150 | + |
| 151 | +def test_async_client_wraps_timeout_isfinite_failures( |
| 152 | + monkeypatch: pytest.MonkeyPatch, |
| 153 | +): |
| 154 | + def _raise_isfinite_error(value: float) -> bool: |
| 155 | + _ = value |
| 156 | + raise OverflowError("finite check overflow") |
| 157 | + |
| 158 | + monkeypatch.setattr(timeout_helpers.math, "isfinite", _raise_isfinite_error) |
| 159 | + |
| 160 | + with pytest.raises(HyperbrowserError, match="timeout must be finite") as exc_info: |
| 161 | + AsyncHyperbrowser(api_key="test-key", timeout=1) |
| 162 | + |
| 163 | + assert exc_info.value.original_error is not None |
0 commit comments