def test_remove_proxy(): """ Test removing proxy from environ. """ if 'HTTP_PROXY' in os.environ: del os.environ['HTTP_PROXY'] assert get_proxy() == None os.environ['HTTP_PROXY'] = 'user:[email protected]:port' assert get_proxy() == 'user:[email protected]:port' del os.environ['HTTP_PROXY'] assert get_proxy('server.com') == 'server.com' assert get_proxy('server.com:80') == 'server.com:80' assert get_proxy('user:[email protected]:3128') == 'user:[email protected]:3128'
def test_remove_proxy(): """ Test removing proxy from environ. """ if "HTTP_PROXY" in os.environ: del os.environ["HTTP_PROXY"] assert get_proxy() == None os.environ["HTTP_PROXY"] = "user:[email protected]:port" assert get_proxy() == "user:[email protected]:port" del os.environ["HTTP_PROXY"] assert get_proxy("server.com") == "server.com" assert get_proxy("server.com:80") == "server.com:80" assert get_proxy("user:[email protected]:3128") == "user:[email protected]:3128"
def test_get_proxy(): """ Test get_proxy returns correct proxy info. """ # monkeypatch getpass.getpass, to avoid asking for a password old_getpass = getpass.getpass getpass.getpass = new_getpass # Test it: assert get_proxy('user:@server.com:3128') == 'user:@server.com:3128' assert get_proxy('[email protected]:3128') == 'user:[email protected]:3128' # Undo monkeypatch getpass.getpass = old_getpass
def test_get_proxy(): """ Test get_proxy returns correct proxy info. """ # monkeypatch getpass.getpass, to avoid asking for a password old_getpass = getpass.getpass getpass.getpass = new_getpass # Test it: assert get_proxy("user:@server.com:3128") == "user:@server.com:3128" assert get_proxy("[email protected]:3128") == "user:[email protected]:3128" # Undo monkeypatch getpass.getpass = old_getpass