def test_with_error_handling_ignore(self): result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), IGNORE) self.assertIsNone(result) result = Transport._with_error_handling(FakeResponse(), RuntimeError(), IGNORE) self.assertIsNone(result) result = Transport._with_error_handling(FakeResponse(), HTTPError(), IGNORE) self.assertIsNone(result) result = Transport._with_error_handling(FakeResponse(content='{"valid": 1}'), HTTPError(), IGNORE) self.assertIsNotNone(result) self.assertTrue('valid' in result) self.assertEqual(result['valid'], 1)
def test_with_error_handling_ignore(self): result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), IGNORE, 'json').parsed self.assertIsNone(result) result = Transport._with_error_handling(FakeResponse(), RuntimeError(), IGNORE, 'json').parsed self.assertIsNone(result) result = Transport._with_error_handling(FakeResponse(), HTTPError(), IGNORE, 'json').parsed self.assertIsNone(result) result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), IGNORE, 'xml').parsed self.assertIsNone(result) result = Transport._with_error_handling(FakeResponse(), RuntimeError(), IGNORE, 'xml').parsed self.assertIsNone(result) result = Transport._with_error_handling(FakeResponse(), HTTPError(), IGNORE, 'xml').parsed self.assertIsNone(result) result = Transport._with_error_handling( FakeResponse(content='{"valid": 1}'), HTTPError(), IGNORE, 'json').parsed self.assertIsNotNone(result) self.assertTrue('valid' in result) self.assertEqual(result['valid'], 1) result = Transport._with_error_handling( FakeResponse(content='<valid>1</valid>'), HTTPError(), IGNORE, 'xml').parsed self.assertIsNotNone(result) self.assertEqual(result.tag, 'valid') self.assertEqual(result.text, '1')
def test_with_error_handling_ignore(self): result = Transport._with_error_handling( FakeResponse(), EmptyResponse(), IGNORE, 'json').parsed self.assertEqual(None, result) result = Transport._with_error_handling( FakeResponse(), RuntimeError(), IGNORE, 'json').parsed self.assertEqual(None, result) result = Transport._with_error_handling( FakeResponse(), HTTPError(), IGNORE, 'json').parsed self.assertEqual(None, result) try: result = Transport._with_error_handling( FakeResponse(), EmptyResponse(), IGNORE, 'xml').parsed self.assertEqual(None, result) result = Transport._with_error_handling( FakeResponse(), RuntimeError(), IGNORE, 'xml').parsed self.assertEqual(None, result) result = Transport._with_error_handling( FakeResponse(), HTTPError(), IGNORE, 'xml').parsed self.assertEqual(None, result) except Exception as e: # Exception for Python 2.6 print(e) result = Transport._with_error_handling( FakeResponse(content='{"valid": 1}'), HTTPError(), IGNORE, 'json').parsed self.assertTrue(None != result) self.assertTrue('valid' in result) self.assertEqual(result['valid'], 1) result = Transport._with_error_handling( FakeResponse(content='<valid>1</valid>'), HTTPError(), IGNORE, 'xml').parsed self.assertTrue(None != result) self.assertEqual(result.tag, 'valid') self.assertEqual(result.text, '1')
def test_with_error_handling_ignore(self): result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), IGNORE, "json").parsed self.assertEqual(None, result) result = Transport._with_error_handling(FakeResponse(), RuntimeError(), IGNORE, "json").parsed self.assertEqual(None, result) result = Transport._with_error_handling(FakeResponse(), HTTPError(), IGNORE, "json").parsed self.assertEqual(None, result) try: result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), IGNORE, "xml").parsed self.assertEqual(None, result) result = Transport._with_error_handling(FakeResponse(), RuntimeError(), IGNORE, "xml").parsed self.assertEqual(None, result) result = Transport._with_error_handling(FakeResponse(), HTTPError(), IGNORE, "xml").parsed self.assertEqual(None, result) except Exception as e: # Exception for Python 2.6 print(e) result = Transport._with_error_handling( FakeResponse(content='{"valid": 1}'), HTTPError(), IGNORE, "json" ).parsed self.assertTrue(None != result) self.assertTrue("valid" in result) self.assertEqual(result["valid"], 1) result = Transport._with_error_handling( FakeResponse(content="<valid>1</valid>"), HTTPError(), IGNORE, "xml" ).parsed self.assertTrue(None != result) self.assertEqual(result.tag, "valid") self.assertEqual(result.text, "1")
def test_with_error_handling_strict(self): with self.assertRaises(RuntimeError): Transport._with_error_handling(FakeResponse(), RuntimeError, STRICT) with self.assertRaises(HTTPError): Transport._with_error_handling(FakeResponse(status_code=404), HTTPError(), STRICT) with self.assertRaises(HTTPError) as e: Transport._with_error_handling(FakeResponse(status_code=429), HTTPError('429: '), STRICT) self.assertEqual(e.message, '429: Too many requests in the last minute.') with self.assertRaises(HTTPError) as e: Transport._with_error_handling(FakeResponse(status_code=400), HTTPError('400'), STRICT) self.assertEqual(e.message, '400') with self.assertRaises(HTTPError) as e: Transport._with_error_handling(FakeResponse(status_code=400, content='{"ValidationErrors": ' '[{"Message": "1"}, {"Message": "2"}]}'), HTTPError('400'), STRICT) self.assertEqual(e.message, '400: %s' % '\n\t'.join(['1', '2']))
def test_with_error_handling_ignore(self): result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), IGNORE, 'json').parsed self.assertEqual(None, result) result = Transport._with_error_handling(FakeResponse(), RuntimeError(), IGNORE, 'json').parsed self.assertEqual(None, result) result = Transport._with_error_handling(FakeResponse(), HTTPError(), IGNORE, 'json').parsed self.assertEqual(None, result) try: result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), IGNORE, 'xml').parsed self.assertEqual(None, result) result = Transport._with_error_handling(FakeResponse(), RuntimeError(), IGNORE, 'xml').parsed self.assertEqual(None, result) result = Transport._with_error_handling(FakeResponse(), HTTPError(), IGNORE, 'xml').parsed self.assertEqual(None, result) except Exception as e: # Exception for Python 2.6 print(e) result = Transport._with_error_handling( FakeResponse(content='{"valid": 1}'), HTTPError(), IGNORE, 'json').parsed self.assertTrue(result is not None) self.assertTrue('valid' in result) self.assertEqual(result['valid'], 1) result = Transport._with_error_handling( FakeResponse(content='<valid>1</valid>'), HTTPError(), IGNORE, 'xml').parsed self.assertTrue(result is not None) self.assertEqual(result.tag, 'valid') self.assertEqual(result.text, '1')
def test_with_error_handling_graceful(self): result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), GRACEFUL) self.assertIsNone(result) result = Transport._with_error_handling(FakeResponse(content='{"valid": 1}', status_code=429), HTTPError(), GRACEFUL) self.assertIsNotNone(result) self.assertTrue('valid' in result) self.assertEqual(result['valid'], 1) result = Transport._with_error_handling(FakeResponse(content='invalid', status_code=429), HTTPError(), GRACEFUL) self.assertIsNone(result) with self.assertRaises(HTTPError): Transport._with_error_handling(FakeResponse(), HTTPError(), GRACEFUL) with self.assertRaises(RuntimeError): Transport._with_error_handling(FakeResponse(), RuntimeError(), GRACEFUL)
def test_with_error_handling_graceful(self): result = Transport._with_error_handling( FakeResponse(), EmptyResponse(), GRACEFUL, 'json') self.assertTrue(result is not None) self.assertEqual(None, result.parsed) result = Transport._with_error_handling( FakeResponse(), EmptyResponse(), GRACEFUL, 'xml') self.assertTrue(result is not None) self.assertEqual(None, result.parsed) result = Transport._with_error_handling( FakeResponse(content='{"valid": 1}', status_code=429), HTTPError(), GRACEFUL, 'json' ).parsed self.assertTrue(result is not None) self.assertTrue('valid' in result) self.assertEqual(result['valid'], 1) result = Transport._with_error_handling( FakeResponse(content='<valid>1</valid>', status_code=429), HTTPError(), GRACEFUL, 'xml' ).parsed self.assertTrue(result is not None) self.assertEqual(result.tag, 'valid') self.assertEqual(result.text, '1') result = Transport._with_error_handling( FakeResponse(content='invalid', status_code=429), HTTPError(), GRACEFUL, 'json' ).parsed self.assertEqual(None, result) try: result = Transport._with_error_handling( FakeResponse(content='invalid', status_code=429), HTTPError(), GRACEFUL, 'xml' ).parsed except Exception as e: print(e) self.assertEqual(None, result) for format in ['json', 'xml']: self.assertRaises(HTTPError, Transport._with_error_handling, FakeResponse(), HTTPError(), GRACEFUL, format) self.assertRaises(RuntimeError, Transport._with_error_handling, FakeResponse(), RuntimeError(), GRACEFUL, format)
def test_with_error_handling_graceful(self): result = Transport._with_error_handling( FakeResponse(), EmptyResponse(), GRACEFUL, 'json') self.assertTrue(None != result) self.assertEqual(None, result.parsed) result = Transport._with_error_handling( FakeResponse(), EmptyResponse(), GRACEFUL, 'xml') self.assertTrue(None != result) self.assertEqual(None, result.parsed) result = Transport._with_error_handling(FakeResponse(content='{"valid": 1}', status_code=429), HTTPError(), GRACEFUL, 'json').parsed self.assertTrue(None != result) self.assertTrue('valid' in result) self.assertEqual(result['valid'], 1) result = Transport._with_error_handling(FakeResponse(content='<valid>1</valid>', status_code=429), HTTPError(), GRACEFUL, 'xml').parsed self.assertTrue(None != result) self.assertEqual(result.tag, 'valid') self.assertEqual(result.text, '1') result = Transport._with_error_handling(FakeResponse(content='invalid', status_code=429), HTTPError(), GRACEFUL, 'json').parsed self.assertEqual(None, result) try: result = Transport._with_error_handling(FakeResponse(content='invalid', status_code=429), HTTPError(), GRACEFUL, 'xml').parsed except Exception as e: print(e) self.assertEqual(None, result) for format in ['json', 'xml']: self.assertRaises(HTTPError, Transport._with_error_handling, FakeResponse(), HTTPError(), GRACEFUL, format) self.assertRaises(RuntimeError, Transport._with_error_handling, FakeResponse(), RuntimeError(), GRACEFUL, format)
def test_with_error_handling_graceful(self): result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), GRACEFUL, "json") self.assertTrue(None != result) self.assertEqual(None, result.parsed) result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), GRACEFUL, "xml") self.assertTrue(None != result) self.assertEqual(None, result.parsed) result = Transport._with_error_handling( FakeResponse(content='{"valid": 1}', status_code=429), HTTPError(), GRACEFUL, "json" ).parsed self.assertTrue(None != result) self.assertTrue("valid" in result) self.assertEqual(result["valid"], 1) result = Transport._with_error_handling( FakeResponse(content="<valid>1</valid>", status_code=429), HTTPError(), GRACEFUL, "xml" ).parsed self.assertTrue(None != result) self.assertEqual(result.tag, "valid") self.assertEqual(result.text, "1") result = Transport._with_error_handling( FakeResponse(content="invalid", status_code=429), HTTPError(), GRACEFUL, "json" ).parsed self.assertEqual(None, result) try: result = Transport._with_error_handling( FakeResponse(content="invalid", status_code=429), HTTPError(), GRACEFUL, "xml" ).parsed except Exception as e: print(e) self.assertEqual(None, result) for format in ["json", "xml"]: self.assertRaises(HTTPError, Transport._with_error_handling, FakeResponse(), HTTPError(), GRACEFUL, format) self.assertRaises( RuntimeError, Transport._with_error_handling, FakeResponse(), RuntimeError(), GRACEFUL, format )
def test_with_error_handling_strict(self): for format in ['json', 'xml']: try: self.assertRaises(RuntimeError, Transport._with_error_handling, FakeResponse(), RuntimeError, STRICT, format) self.assertRaises(HTTPError, Transport._with_error_handling, FakeResponse(status_code=404), HTTPError(), STRICT, format) self.assertRaises(HTTPError, Transport._with_error_handling, FakeResponse(status_code=429), HTTPError('429: '), STRICT, format) try: Transport._with_error_handling( FakeResponse(status_code=429), HTTPError('429: '), STRICT, format) except HTTPError as e: self.assertEqual( e.message, '429: Too many requests in the last minute.') self.assertRaises(HTTPError, Transport._with_error_handling, FakeResponse(status_code=400), HTTPError('400'), STRICT, format) try: Transport._with_error_handling( FakeResponse(status_code=400), HTTPError('400'), STRICT, format) except HTTPError as e: self.assertEqual(e.message, '400') except Exception as e: # Exception for Python 2.6 print(e) self.assertRaises( HTTPError, Transport._with_error_handling, FakeResponse(status_code=400, content='{"ValidationErrors": ' '[{"Message": "1"}, {"Message": "2"}]}'), HTTPError('400'), STRICT, 'json') try: Transport._with_error_handling( FakeResponse(status_code=400, content='{"ValidationErrors": ' '[{"Message": "1"}, {"Message": "2"}]}'), HTTPError('400'), STRICT, 'json') except HTTPError as e: try: self.assertEqual(e.message, ('400: %s' % '\n\t'.join(['1', '2']))) except AttributeError as e: # Exception for Python 3 print(e) try: self.assertRaises( HTTPError, Transport._with_error_handling, FakeResponse(status_code=400, content='<Root><ValidationErrors>' '<ValidationErrorDto>' '<Message>1</Message' '</ValidationErrorDto>' '<ValidationErrorDto>' '<Message>2</Message' '</ValidationErrorDto>' '</ValidationErrors></Root>'), HTTPError('400'), STRICT, 'xml') except Exception as e: # Exception for Python 2.6 print(e) try: try: Transport._with_error_handling( FakeResponse(status_code=400, content='<Root><ValidationErrors>' '<ValidationErrorDto>' '<Message>1</Message' '</ValidationErrorDto>' '<ValidationErrorDto>' '<Message>2</Message' '</ValidationErrorDto>' '</ValidationErrors></Root>'), HTTPError('400'), STRICT, 'xml') except Exception as e: # Exception for Python 2.6 print(e) except HTTPError as e: try: self.assertEqual(e.message, '400') except AttributeError as e: # Exception for Python 3 print(e)
def test_with_error_handling_strict(self): with self.assertRaises(RuntimeError): Transport._with_error_handling(FakeResponse(), RuntimeError, STRICT, 'json') with self.assertRaises(RuntimeError): Transport._with_error_handling(FakeResponse(), RuntimeError, STRICT, 'xml') with self.assertRaises(HTTPError): Transport._with_error_handling(FakeResponse(status_code=404), HTTPError(), STRICT, 'json') with self.assertRaises(HTTPError): Transport._with_error_handling(FakeResponse(status_code=404), HTTPError(), STRICT, 'xml') with self.assertRaises(HTTPError) as e: Transport._with_error_handling(FakeResponse(status_code=429), HTTPError('429: '), STRICT, 'json') self.assertEqual(e.message, '429: Too many requests in the last minute.') with self.assertRaises(HTTPError) as e: Transport._with_error_handling(FakeResponse(status_code=429), HTTPError('429: '), STRICT, 'xml') self.assertEqual(e.message, '429: Too many requests in the last minute.') with self.assertRaises(HTTPError) as e: Transport._with_error_handling(FakeResponse(status_code=400), HTTPError('400'), STRICT, 'json') self.assertEqual(e.message, '400') with self.assertRaises(HTTPError) as e: Transport._with_error_handling(FakeResponse(status_code=400), HTTPError('400'), STRICT, 'xml') self.assertEqual(e.message, '400') with self.assertRaises(HTTPError) as e: Transport._with_error_handling( FakeResponse(status_code=400, content='{"ValidationErrors": ' '[{"Message": "1"}, {"Message": "2"}]}'), HTTPError('400'), STRICT, 'json') self.assertEqual(e.message, '400: %s' % '\n\t'.join(['1', '2'])) with self.assertRaises(HTTPError) as e: Transport._with_error_handling( FakeResponse(status_code=400, content='<Root><ValidationErrors>' '<ValidationErrorDto>' '<Message>1</Message' '</ValidationErrorDto>' '<ValidationErrorDto>' '<Message>2</Message' '</ValidationErrorDto>' '</ValidationErrors></Root>'), HTTPError('400'), STRICT, 'xml') self.assertEqual(e.message, '400: %s' % '\n\t'.join(['1', '2']))
def test_with_error_handling_graceful(self): result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), GRACEFUL, 'json') self.assertIsNotNone(result) self.assertIsNone(result.parsed) result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), GRACEFUL, 'xml') self.assertIsNotNone(result) self.assertIsNone(result.parsed) result = Transport._with_error_handling( FakeResponse(content='{"valid": 1}', status_code=429), HTTPError(), GRACEFUL, 'json').parsed self.assertIsNotNone(result) self.assertTrue('valid' in result) self.assertEqual(result['valid'], 1) result = Transport._with_error_handling( FakeResponse(content='<valid>1</valid>', status_code=429), HTTPError(), GRACEFUL, 'xml').parsed self.assertIsNotNone(result) self.assertEqual(result.tag, 'valid') self.assertEqual(result.text, '1') result = Transport._with_error_handling( FakeResponse(content='invalid', status_code=429), HTTPError(), GRACEFUL, 'json').parsed self.assertIsNone(result) result = Transport._with_error_handling( FakeResponse(content='invalid', status_code=429), HTTPError(), GRACEFUL, 'xml').parsed self.assertIsNone(result) with self.assertRaises(HTTPError): Transport._with_error_handling(FakeResponse(), HTTPError(), GRACEFUL, 'json') with self.assertRaises(RuntimeError): Transport._with_error_handling(FakeResponse(), RuntimeError(), GRACEFUL, 'json') with self.assertRaises(HTTPError): Transport._with_error_handling(FakeResponse(), HTTPError(), GRACEFUL, 'xml') with self.assertRaises(RuntimeError): Transport._with_error_handling(FakeResponse(), RuntimeError(), GRACEFUL, 'xml')
def test_with_error_handling_graceful(self): result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), GRACEFUL, 'json') self.assertIsNotNone(result) self.assertIsNone(result.parsed) result = Transport._with_error_handling(FakeResponse(), EmptyResponse(), GRACEFUL, 'xml') self.assertIsNotNone(result) self.assertIsNone(result.parsed) result = Transport._with_error_handling(FakeResponse(content='{"valid": 1}', status_code=429), HTTPError(), GRACEFUL, 'json').parsed self.assertIsNotNone(result) self.assertTrue('valid' in result) self.assertEqual(result['valid'], 1) result = Transport._with_error_handling(FakeResponse(content='<valid>1</valid>', status_code=429), HTTPError(), GRACEFUL, 'xml').parsed self.assertIsNotNone(result) self.assertEqual(result.tag, 'valid') self.assertEqual(result.text, '1') result = Transport._with_error_handling(FakeResponse(content='invalid', status_code=429), HTTPError(), GRACEFUL, 'json').parsed self.assertIsNone(result) result = Transport._with_error_handling(FakeResponse(content='invalid', status_code=429), HTTPError(), GRACEFUL, 'xml').parsed self.assertIsNone(result) with self.assertRaises(HTTPError): Transport._with_error_handling(FakeResponse(), HTTPError(), GRACEFUL, 'json') with self.assertRaises(RuntimeError): Transport._with_error_handling(FakeResponse(), RuntimeError(), GRACEFUL, 'json') with self.assertRaises(HTTPError): Transport._with_error_handling(FakeResponse(), HTTPError(), GRACEFUL, 'xml') with self.assertRaises(RuntimeError): Transport._with_error_handling(FakeResponse(), RuntimeError(), GRACEFUL, 'xml')
def test_with_error_handling_strict(self): for format in ['json', 'xml']: try: self.assertRaises(RuntimeError, Transport._with_error_handling, FakeResponse(), RuntimeError, STRICT, format) self.assertRaises(HTTPError, Transport._with_error_handling, FakeResponse(status_code=404), HTTPError(), STRICT, format) self.assertRaises(HTTPError, Transport._with_error_handling, FakeResponse(status_code=429), HTTPError('429: '), STRICT, format) try: Transport._with_error_handling( FakeResponse(status_code=429), HTTPError('429: '), STRICT, format) except HTTPError as e: self.assertEqual( e.message, '429: Too many requests in the last minute.') self.assertRaises(HTTPError, Transport._with_error_handling, FakeResponse(status_code=400), HTTPError('400'), STRICT, format) try: Transport._with_error_handling( FakeResponse(status_code=400), HTTPError('400'), STRICT, format) except HTTPError as e: self.assertEqual(e.message, '400') except Exception as e: # Exception for Python 2.6 print(e) self.assertRaises(HTTPError, Transport._with_error_handling, FakeResponse(status_code=400, content='{"ValidationErrors": ' '[{"Message": "1"}, {"Message": "2"}]}'), HTTPError('400'), STRICT, 'json') try: Transport._with_error_handling(FakeResponse(status_code=400, content='{"ValidationErrors": ' '[{"Message": "1"}, {"Message": "2"}]}'), HTTPError('400'), STRICT, 'json') except HTTPError as e: try: self.assertEqual( e.message, ('400: %s' % '\n\t'.join(['1', '2']))) except AttributeError as e: # Exception for Python 3 print(e) try: self.assertRaises(HTTPError, Transport._with_error_handling, FakeResponse(status_code=400, content='<Root><ValidationErrors>' '<ValidationErrorDto>' '<Message>1</Message' '</ValidationErrorDto>' '<ValidationErrorDto>' '<Message>2</Message' '</ValidationErrorDto>' '</ValidationErrors></Root>'), HTTPError('400'), STRICT, 'xml') except Exception as e: # Exception for Python 2.6 print(e) try: try: Transport._with_error_handling(FakeResponse(status_code=400, content='<Root><ValidationErrors>' '<ValidationErrorDto>' '<Message>1</Message' '</ValidationErrorDto>' '<ValidationErrorDto>' '<Message>2</Message' '</ValidationErrorDto>' '</ValidationErrors></Root>'), HTTPError('400'), STRICT, 'xml') except Exception as e: # Exception for Python 2.6 print(e) except HTTPError as e: try: self.assertEqual(e.message, '400') except AttributeError as e: # Exception for Python 3 print(e)
def test_with_error_handling_strict(self): for format in ["json", "xml"]: try: self.assertRaises( RuntimeError, Transport._with_error_handling, FakeResponse(), RuntimeError, STRICT, format ) self.assertRaises( HTTPError, Transport._with_error_handling, FakeResponse(status_code=404), HTTPError(), STRICT, format, ) self.assertRaises( HTTPError, Transport._with_error_handling, FakeResponse(status_code=429), HTTPError("429: "), STRICT, format, ) try: Transport._with_error_handling(FakeResponse(status_code=429), HTTPError("429: "), STRICT, format) except HTTPError as e: self.assertEqual(e.message, "429: Too many requests in the last minute.") self.assertRaises( HTTPError, Transport._with_error_handling, FakeResponse(status_code=400), HTTPError("400"), STRICT, format, ) try: Transport._with_error_handling(FakeResponse(status_code=400), HTTPError("400"), STRICT, format) except HTTPError as e: self.assertEqual(e.message, "400") except Exception as e: # Exception for Python 2.6 print(e) self.assertRaises( HTTPError, Transport._with_error_handling, FakeResponse(status_code=400, content='{"ValidationErrors": ' '[{"Message": "1"}, {"Message": "2"}]}'), HTTPError("400"), STRICT, "json", ) try: Transport._with_error_handling( FakeResponse(status_code=400, content='{"ValidationErrors": ' '[{"Message": "1"}, {"Message": "2"}]}'), HTTPError("400"), STRICT, "json", ) except HTTPError as e: try: self.assertEqual(e.message, ("400: %s" % "\n\t".join(["1", "2"]))) except AttributeError as e: # Exception for Python 3 print(e) try: self.assertRaises( HTTPError, Transport._with_error_handling, FakeResponse( status_code=400, content="<Root><ValidationErrors>" "<ValidationErrorDto>" "<Message>1</Message" "</ValidationErrorDto>" "<ValidationErrorDto>" "<Message>2</Message" "</ValidationErrorDto>" "</ValidationErrors></Root>", ), HTTPError("400"), STRICT, "xml", ) except Exception as e: # Exception for Python 2.6 print(e) try: try: Transport._with_error_handling( FakeResponse( status_code=400, content="<Root><ValidationErrors>" "<ValidationErrorDto>" "<Message>1</Message" "</ValidationErrorDto>" "<ValidationErrorDto>" "<Message>2</Message" "</ValidationErrorDto>" "</ValidationErrors></Root>", ), HTTPError("400"), STRICT, "xml", ) except Exception as e: # Exception for Python 2.6 print(e) except HTTPError as e: try: self.assertEqual(e.message, "400") except AttributeError as e: # Exception for Python 3 print(e)