本文整理汇总了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)
示例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)
示例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])
示例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)
示例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', '/')
示例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", "/")