httplib2_test.py 文件源码

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

项目:httplib2shim 作者: GoogleCloudPlatform 项目源码 文件源码
def testGetViaHttpsKeyCert(self):
        #  At this point I can only test
        #  that the key and cert files are passed in
        #  correctly to httplib. It would be nice to have
        #  a real https endpoint to test against.
        http = httplib2.Http(timeout=2)

        http.add_certificate("akeyfile", "acertfile", "bitworking.org")
        try:
            (response, content) = http.request("https://bitworking.org", "GET")
        except AttributeError:
            self.assertEqual(
                http.connections["https:bitworking.org"].key_file, "akeyfile")
            self.assertEqual(
                http.connections[
                    "https:bitworking.org"].cert_file, "acertfile")
        except IOError:
            # Skip on 3.2
            pass

        try:
            (response, content) = http.request(
                "https://notthere.bitworking.org", "GET")
        except httplib2.ServerNotFoundError:
            self.assertEqual(
                http.connections["https:notthere.bitworking.org"].key_file,
                None)
            self.assertEqual(
                http.connections["https:notthere.bitworking.org"].cert_file,
                None)
        except IOError:
            # Skip on 3.2
            pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号