当前位置: 首页>>代码示例>>Python>>正文


Python HTTPSConnectionPool.ConnectionCls方法代码示例

本文整理汇总了Python中urllib3.HTTPSConnectionPool.ConnectionCls方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPSConnectionPool.ConnectionCls方法的具体用法?Python HTTPSConnectionPool.ConnectionCls怎么用?Python HTTPSConnectionPool.ConnectionCls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urllib3.HTTPSConnectionPool的用法示例。


在下文中一共展示了HTTPSConnectionPool.ConnectionCls方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_no_ssl

# 需要导入模块: from urllib3 import HTTPSConnectionPool [as 别名]
# 或者: from urllib3.HTTPSConnectionPool import ConnectionCls [as 别名]
 def test_no_ssl(self):
     pool = HTTPSConnectionPool(self.host, self.port)
     pool.ConnectionCls = None
     self.addCleanup(pool.close)
     self.assertRaises(SSLError, pool._new_conn)
     with self.assertRaises(MaxRetryError) as cm:
         pool.request('GET', '/', retries=0)
     self.assertIsInstance(cm.exception.reason, SSLError)
开发者ID:christophermca,项目名称:dotfiles,代码行数:10,代码来源:test_https.py

示例2: test_unverified_ssl

# 需要导入模块: from urllib3 import HTTPSConnectionPool [as 别名]
# 或者: from urllib3.HTTPSConnectionPool import ConnectionCls [as 别名]
    def test_unverified_ssl(self):
        """ Test that bare HTTPSConnection can connect, make requests """
        pool = HTTPSConnectionPool(self.host, self.port)
        pool.ConnectionCls = UnverifiedHTTPSConnection

        with mock.patch('warnings.warn') as warn:
            r = pool.request('GET', '/')
            self.assertEqual(r.status, 200)
            self.assertTrue(warn.called)

            call, = warn.call_args_list
            category = call[0][1]
            self.assertEqual(category, InsecureRequestWarning)
开发者ID:JasonRepo,项目名称:urllib3,代码行数:15,代码来源:test_https.py

示例3: test_unverified_ssl

# 需要导入模块: from urllib3 import HTTPSConnectionPool [as 别名]
# 或者: from urllib3.HTTPSConnectionPool import ConnectionCls [as 别名]
    def test_unverified_ssl(self):
        """ Test that bare HTTPSConnection can connect, make requests """
        pool = HTTPSConnectionPool(self.host, self.port)
        pool.ConnectionCls = UnverifiedHTTPSConnection
        self.addCleanup(pool.close)

        with mock.patch('warnings.warn') as warn:
            r = pool.request('GET', '/')
            self.assertEqual(r.status, 200)
            self.assertTrue(warn.called)

            # Modern versions of Python, or systems using PyOpenSSL, only emit
            # the unverified warning. Older systems may also emit other
            # warnings, which we want to ignore here.
            calls = warn.call_args_list
            self.assertIn(InsecureRequestWarning, [x[0][1] for x in calls])
开发者ID:christophermca,项目名称:dotfiles,代码行数:18,代码来源:test_https.py

示例4: test_unverified_ssl

# 需要导入模块: from urllib3 import HTTPSConnectionPool [as 别名]
# 或者: from urllib3.HTTPSConnectionPool import ConnectionCls [as 别名]
    def test_unverified_ssl(self):
        """ Test that bare HTTPSConnection can connect, make requests """
        pool = HTTPSConnectionPool(self.host, self.port)
        pool.ConnectionCls = UnverifiedHTTPSConnection

        with mock.patch('warnings.warn') as warn:
            r = pool.request('GET', '/')
            self.assertEqual(r.status, 200)
            self.assertTrue(warn.called)

            # Modern versions of Python, or systems using PyOpenSSL, only emit
            # the unverified warning. Older systems may also emit other
            # warnings, which we want to ignore here.
            calls = warn.call_args_list
            if sys.version_info >= (2, 7, 9) or util.IS_PYOPENSSL:
                category = calls[0][0][1]
            elif util.HAS_SNI:
                category = calls[1][0][1]
            else:
                category = calls[2][0][1]
            self.assertEqual(category, InsecureRequestWarning)
开发者ID:JioCloudVPC,项目名称:urllib3,代码行数:23,代码来源:test_https.py

示例5: test_no_ssl

# 需要导入模块: from urllib3 import HTTPSConnectionPool [as 别名]
# 或者: from urllib3.HTTPSConnectionPool import ConnectionCls [as 别名]
 def test_no_ssl(self):
     pool = HTTPSConnectionPool(self.host, self.port)
     pool.ConnectionCls = None
     self.addCleanup(pool.close)
     self.assertRaises(SSLError, pool._new_conn)
     self.assertRaises(SSLError, pool.request, 'GET', '/')
开发者ID:Lukasa,项目名称:urllib3,代码行数:8,代码来源:test_https.py

示例6: test_no_ssl

# 需要导入模块: from urllib3 import HTTPSConnectionPool [as 别名]
# 或者: from urllib3.HTTPSConnectionPool import ConnectionCls [as 别名]
 def test_no_ssl(self):
     pool = HTTPSConnectionPool(self.host, self.port)
     pool.ConnectionCls = None
     self.assertRaises(SSLError, pool._new_conn)
     self.assertRaises(SSLError, pool.request, "GET", "/")
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:7,代码来源:test_https.py


注:本文中的urllib3.HTTPSConnectionPool.ConnectionCls方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。