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


Python urllib.proxy_bypass_environment方法代码示例

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


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

示例1: test_getproxies_environment_prefer_lowercase

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import proxy_bypass_environment [as 别名]
def test_getproxies_environment_prefer_lowercase(self):
        # Test lowercase preference with removal
        os.environ['no_proxy'] = ''
        os.environ['No_Proxy'] = 'localhost'
        self.assertFalse(urllib.proxy_bypass_environment('localhost'))
        self.assertFalse(urllib.proxy_bypass_environment('arbitrary'))
        os.environ['http_proxy'] = ''
        os.environ['HTTP_PROXY'] = 'http://somewhere:3128'
        proxies = urllib.getproxies_environment()
        self.assertEqual({}, proxies)
        # Test lowercase preference of proxy bypass and correct matching including ports
        os.environ['no_proxy'] = 'localhost, noproxy.com, my.proxy:1234'
        os.environ['No_Proxy'] = 'xyz.com'
        self.assertTrue(urllib.proxy_bypass_environment('localhost'))
        self.assertTrue(urllib.proxy_bypass_environment('noproxy.com:5678'))
        self.assertTrue(urllib.proxy_bypass_environment('my.proxy:1234'))
        self.assertFalse(urllib.proxy_bypass_environment('my.proxy'))
        self.assertFalse(urllib.proxy_bypass_environment('arbitrary'))
        # Test lowercase preference with replacement
        os.environ['http_proxy'] = 'http://somewhere:3128'
        os.environ['Http_Proxy'] = 'http://somewhereelse:3128'
        proxies = urllib.getproxies_environment()
        self.assertEqual('http://somewhere:3128', proxies['http']) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_urllib.py

示例2: test_getproxies_environment_keep_no_proxies

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import proxy_bypass_environment [as 别名]
def test_getproxies_environment_keep_no_proxies(self):
        self.env.set('NO_PROXY', 'localhost')
        proxies = urllib.getproxies_environment()
        # getproxies_environment use lowered case truncated (no '_proxy') keys
        self.assertEqual('localhost', proxies['no'])
        # List of no_proxies with space.
        self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com:1234')
        self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com'))
        self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com:8888'))
        self.assertTrue(urllib.proxy_bypass_environment('newdomain.com:1234')) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_urllib.py

示例3: test_proxy_bypass_environment_host_match

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import proxy_bypass_environment [as 别名]
def test_proxy_bypass_environment_host_match(self):
        bypass = urllib.proxy_bypass_environment
        self.env.set('NO_PROXY',
                     'localhost, anotherdomain.com, newdomain.com:1234, .d.o.t')
        self.assertTrue(bypass('localhost'))
        self.assertTrue(bypass('LocalHost'))                 # MixedCase
        self.assertTrue(bypass('LOCALHOST'))                 # UPPERCASE
        self.assertTrue(bypass('newdomain.com:1234'))
        self.assertTrue(bypass('foo.d.o.t'))                 # issue 29142
        self.assertTrue(bypass('anotherdomain.com:8888'))
        self.assertTrue(bypass('www.newdomain.com:1234'))
        self.assertFalse(bypass('prelocalhost'))
        self.assertFalse(bypass('newdomain.com'))            # no port
        self.assertFalse(bypass('newdomain.com:1235'))       # wrong port 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:test_urllib.py

示例4: test_getproxies_environment_keep_no_proxies

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import proxy_bypass_environment [as 别名]
def test_getproxies_environment_keep_no_proxies(self):
        self.env.set('NO_PROXY', 'localhost')
        proxies = urllib.getproxies_environment()
        # getproxies_environment use lowered case truncated (no '_proxy') keys
        self.assertEqual('localhost', proxies['no'])
        # List of no_proxies with space.
        self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com')
        self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com')) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:10,代码来源:test_urllib.py

示例5: test_proxy_bypass_environment_host_match

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import proxy_bypass_environment [as 别名]
def test_proxy_bypass_environment_host_match(self):
        bypass = urllib.proxy_bypass_environment
        self.env.set('NO_PROXY',
            'localhost, anotherdomain.com, newdomain.com:1234')
        self.assertTrue(bypass('localhost'))
        self.assertTrue(bypass('LocalHost'))                 # MixedCase
        self.assertTrue(bypass('LOCALHOST'))                 # UPPERCASE
        self.assertTrue(bypass('newdomain.com:1234'))
        self.assertTrue(bypass('anotherdomain.com:8888'))
        self.assertTrue(bypass('www.newdomain.com:1234'))
        self.assertFalse(bypass('prelocalhost'))
        self.assertFalse(bypass('newdomain.com'))            # no port
        self.assertFalse(bypass('newdomain.com:1235'))       # wrong port 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:15,代码来源:test_urllib.py


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