Skip to content

Commit 818f5b2

Browse files
Merge pull request #2923 from VWS-Python/adamtheturtle/fix-coverage
Fix branch coverage in timeout handling
2 parents d9ac542 + 3586524 commit 818f5b2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/mock_vws/_requests_mock_server/decorators.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,16 @@ def wrapped(
154154
# library onto PreparedRequest objects - it is not
155155
# in the requests type stubs.
156156
req_kwargs: dict[str, Any] = getattr(request, "req_kwargs", {})
157-
timeout = req_kwargs.get("timeout")
157+
timeout: tuple[float, float] | float | int | None = req_kwargs.get(
158+
"timeout"
159+
)
158160
# requests allows timeout as a (connect, read)
159161
# tuple. The delay simulates server response
160162
# time, so compare against the read timeout.
161-
effective: float | None = None
162163
if isinstance(timeout, tuple):
163-
if isinstance(timeout[1], (int, float)):
164-
effective = float(timeout[1])
165-
elif isinstance(timeout, (int, float)):
164+
timeout = timeout[1]
165+
effective: float | None = None
166+
if isinstance(timeout, (int, float)):
166167
effective = float(timeout)
167168

168169
if effective is not None and delay_seconds > effective:

0 commit comments

Comments
 (0)