Tests for the proxy support in pyinstall::

    >>> import os
    >>> import pyinstall

Remove proxy from environ:

    >>> if 'HTTP_PROXY' in os.environ:
    ...     del os.environ['HTTP_PROXY']

    >>> print pyinstall.get_proxy()
    None
    >>> os.environ['HTTP_PROXY'] = 'user:pwd@server.com:port'
    >>> pyinstall.get_proxy()
    'user:pwd@server.com:port'
    >>> del os.environ['HTTP_PROXY']
    >>> pyinstall.get_proxy('server.com')
    'server.com'
    >>> pyinstall.get_proxy('server.com:80')
    'server.com:80'
    >>> pyinstall.get_proxy('user:passwd@server.com:3128')
    'user:passwd@server.com:3128'

Now, a quick monkeypatch for getpass.getpass, to avoid asking for a password::

    >>> import getpass
    >>> old_getpass = getpass.getpass
    >>> def new_getpass(prompt, answer='passwd'):
    ...     print '%s%s' % (prompt, answer)
    ...     return answer
    >>> getpass.getpass = new_getpass

Test it:

    >>> pyinstall.get_proxy('user:@server.com:3128')
    'user:@server.com:3128'
    >>> pyinstall.get_proxy('user@server.com:3128')
    Password for user@server.com:3128: passwd
    'user:passwd@server.com:3128'

Undo monkeypatch:

    >>> getpass.getpass = old_getpass
