Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_ConnectionError(self):
with self.assertRaises(exceptions.ConnectionError):
raise exceptions.ConnectionError
def test_ConnectionError(self):
with self.assertRaises(exceptions.ConnectionError):
raise exceptions.ConnectionError
headers={
'Content-Type': 'application/json; charset=utf-8'
},
json=request_dict
)
# Log the response
self.logger.debug('<-- '+r.text \
.replace("\n",'') \
.replace(' ', ' ')
.replace('{ ', '{')
)
except (requests.exceptions.InvalidSchema,
requests.exceptions.RequestException):
raise exceptions.ConnectionError()
# Raise exception the HTTP status code was not 200, and there was no
# response body, because this should be handled.
if not len(r.text) and r.status_code != 200:
raise exceptions.StatusCodeError(r.status_code)
return r.text