test_connector.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:sushy 作者: openstack 项目源码 文件源码
def test_known_http_error(self):
        self.request.return_value.status_code = http_client.BAD_REQUEST
        with open('sushy/tests/unit/json_samples/error.json', 'r') as f:
            self.request.return_value.json.return_value = json.load(f)

        with self.assertRaisesRegex(exceptions.BadRequestError,
                                    'A general error has occurred') as cm:
            self.conn._op('GET', 'http://foo.bar')
        exc = cm.exception
        self.assertEqual(http_client.BAD_REQUEST, exc.status_code)
        self.assertIsNotNone(exc.body)
        self.assertIn('A general error has occurred', exc.detail)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号