[#4535] - Unwrap max retries exceeded errors

This commit is contained in:
Bob Strecansky 2017-08-06 23:30:11 -04:00
parent 521f783020
commit 8555f4a0bd
2 changed files with 6 additions and 2 deletions

View file

@ -647,7 +647,7 @@ class ClientNetwork(object): # pylint: disable=too-many-instance-attributes
err_regex = r".*host='(\S*)'.*Max retries exceeded with url\: (\/\w*).*(\[Errno \d+\])([A-Za-z ]*)"
m = re.match(err_regex, str(e))
if m is None:
raise #pragma: no cover
raise # pragma: no cover
else:
host, path, _err_no, err_msg = m.groups()
raise ValueError("Requesting {0}{1}:{2}".format(host, path, err_msg))

View file

@ -627,11 +627,15 @@ class ClientNetworkTest(unittest.TestCase):
# pylint: disable=protected-access
self.net._send_request('GET', "http://localhost:19123/nonexistent.txt")
# Python Exceptions
# Value Error Generated Exceptions
except ValueError as y:
self.assertEqual("Requesting localhost/nonexistent: "
"Connection refused", str(y))
# Requests Library Exceptions
except requests.exceptions.RequestException as z:
self.assertEqual("('Connection aborted.', error(111, 'Connection refused'))", str(z))
class ClientNetworkWithMockedResponseTest(unittest.TestCase):
"""Tests for acme.client.ClientNetwork which mock out response."""
# pylint: disable=too-many-instance-attributes