def test_attribute_fallback_missing(self):
     """
     Test non-request.Response attributes still raise AttributeError
     """
     err = api.APIError(self.response)
     with self.assertRaises(AttributeError):
         unused = err.undefined_attribute  #pylint: disable=unused-variable
 def test_unauthorized_response_text(self):
     """
     Test APIError parses response.text
     """
     err = api.APIError(self.response)
     expected = "Unauthorized: The request requires user authentication"
     result = str(err)
     self.assertTrue(result.endswith(expected))
 def test_empty_response_text(self):
     """
     Test APIError still works if response.text == ''
     """
     expected = 'failed'
     self.response.text = ''
     err = api.APIError(self.response)
     result = err.message
     self.assertEqual(expected, result)
     with self.assertRaises(api.APIError):
         raise err
 def test_attribute_fallback(self):
     """
     Test missing attributes fall back to request.Response
     """
     err = api.APIError(self.response)
     self.assertEqual(401, err.return_code)