def expected_error_response(self, response):
if isinstance(response, Response): # requests response
# don't want bytes
_txt = response.content.decode('utf8')
response = ErrorResponse().from_json(_txt)
if isinstance(response, ErrorResponse):
self.conv.events.store(EV_PROTOCOL_RESPONSE, response,
sender=self.__class__.__name__)
if response["error"] not in self.expect_error["error"]:
raise Break("Wrong error, got {} expected {}".format(
response["error"], self.expect_error["error"]))
try:
if self.expect_error["stop"]:
raise Break("Stop requested after received expected error")
except KeyError:
pass
else:
self.conv.events.store(EV_FAULT, "Expected error, didn't get it")
raise Break("Did not receive expected error")
return response
评论列表
文章目录