assertRaises无法捕获异常

时间:2016-06-02 06:35:55

标签: python testing

我对assertRaises进行了以下调用,但它无法从ClientException中捕获异常并出现以下错误,并且我对原因进行了适当的解释。感谢。

    with self.assertRaises(ClientException) as cm:
           client.get_object(
               self.r1url, self.r1token, source_container, object_name)
    self.assertEqual(404, cm.exception.http_status)  

错误:

  File "/root/python-swiftclient/swiftclient/client.py", line 1120, in get_object
    raise ClientException.from_response(resp, 'Object GET failed', body)
ClientException: Object GET failed: http://9.148.243.132:8080/v1/AUTH_385efe62b6c84eb4924405c7a391a72b/source-container-a0e3549d-1a4d-4d1b-99ae-e5ab6ad58656/object-cae93916-b6b2-4b6e-8ba2-fcae0854ccb3 404 Not Found  [first 60 chars of response] <html><h1>Not Found</h1><p>The resource could not be found.<

0 个答案:

没有答案