mercredi 1 juin 2016

assertRaises fails to catch exception

I have the following call to assertRaises but it fails to catch an exception from ClientException with the error below and I appropriate an explanation of the reason. Thanks.

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

The error:

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://ift.tt/1t3265f 404 Not Found [first 60 chars of response]

Not Found

The resource could not be found.<

Aucun commentaire:

Enregistrer un commentaire