示例#1
0
def test_get_proxy_from_env():
    from config import config
    config.reset('proxy')

    proxy_skip_address = 'http://skipittyskip'
    os.environ['http_proxy'] = 'http://foo'
    os.environ['https_proxy'] = 'http://bar'
    os.environ['no_proxy'] = proxy_skip_address

    proxy_settings = get_proxy()
    assert proxy_settings is not {}
    assert 'http' in proxy_settings
    assert proxy_settings['http'] == 'http://foo'
    assert 'https' in proxy_settings
    assert proxy_settings['https'] == 'http://bar'
    assert 'no_proxy' in proxy_settings

    no_proxy = proxy_settings['no_proxy'].split(',')
    for host in LOCAL_PROXY_SKIP + [proxy_skip_address]:
        assert host in no_proxy
示例#2
0
def test_get_hostname_conf():
    config.set("hostname", "test-hostname")
    assert get_hostname() == "test-hostname"
    config.reset("hostname")