Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/mock_vws/_requests_mock_server/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,16 @@ def wrapped(
# library onto PreparedRequest objects - it is not
# in the requests type stubs.
req_kwargs: dict[str, Any] = getattr(request, "req_kwargs", {})
timeout = req_kwargs.get("timeout")
timeout: tuple[float, float] | float | int | None = req_kwargs.get(
"timeout"
)
# requests allows timeout as a (connect, read)
# tuple. The delay simulates server response
# time, so compare against the read timeout.
effective: float | None = None
if isinstance(timeout, tuple):
if isinstance(timeout[1], (int, float)):
effective = float(timeout[1])
elif isinstance(timeout, (int, float)):
timeout = timeout[1]
effective: float | None = None
if isinstance(timeout, (int, float)):
effective = float(timeout)

if effective is not None and delay_seconds > effective:
Expand Down