MCPcopy
hub / github.com/urllib3/urllib3 / test_error_message

Method test_error_message

test/test_retry.py:286–313  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

284 Retry(total).increment(method="GET")
285
286 def test_error_message(self) -> None:
287 retry = Retry(total=0)
288 with pytest.raises(MaxRetryError, match="read timed out") as e:
289 retry = retry.increment(
290 method="GET", error=ReadTimeoutError(DUMMY_POOL, "/", "read timed out")
291 )
292 assert "Caused by redirect" not in str(e.value)
293
294 retry = Retry(total=1)
295 retry = retry.increment("POST", "/")
296 with pytest.raises(MaxRetryError, match=ResponseError.GENERIC_ERROR) as e:
297 retry = retry.increment("POST", "/")
298 assert "Caused by redirect" not in str(e.value)
299 assert isinstance(e.value.reason, ResponseError)
300
301 retry = Retry(total=1)
302 response = HTTPResponse(status=500)
303 msg = ResponseError.SPECIFIC_ERROR.format(status_code=500)
304 retry = retry.increment("POST", "/", response=response)
305 with pytest.raises(MaxRetryError, match=msg) as e:
306 retry = retry.increment("POST", "/", response=response)
307 assert "Caused by redirect" not in str(e.value)
308
309 retry = Retry(connect=1)
310 retry = retry.increment(error=ConnectTimeoutError("conntimeout"))
311 with pytest.raises(MaxRetryError, match="conntimeout") as e:
312 retry = retry.increment(error=ConnectTimeoutError("conntimeout"))
313 assert "Caused by redirect" not in str(e.value)
314
315 def test_history(self) -> None:
316 retry = Retry(total=10, allowed_methods=frozenset(["GET", "POST"]))

Callers

nothing calls this directly

Calls 5

incrementMethod · 0.95
RetryClass · 0.90
ReadTimeoutErrorClass · 0.90
HTTPResponseClass · 0.90
ConnectTimeoutErrorClass · 0.90

Tested by

no test coverage detected