Ejemplo n.º 1
0
def test_config_file_override_stack():
    """
    Test config files (global, overriding a global config with a
    local, overriding all with a command line flag).
    
    """
    f, config_file = tempfile.mkstemp('-pip.cfg', 'test-')
    environ = clear_environ(os.environ.copy())
    environ['PIP_CONFIG_FILE'] = config_file # set this to make pip load it
    reset_env(environ)
    write_file(config_file, textwrap.dedent("""\
        [global]
        index-url = http://download.zope.org/ppix
        """))
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Getting page http://download.zope.org/ppix/INITools" in result.stdout
    reset_env(environ)
    write_file(config_file, textwrap.dedent("""\
        [global]
        index-url = http://download.zope.org/ppix
        [install]
        index-url = http://pypi.appspot.com/
        """))
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
    result = run_pip('install', '-vvv', '--index-url', 'http://pypi.python.org/simple', 'INITools', expect_error=True)
    assert "Getting page http://download.zope.org/ppix/INITools" not in result.stdout
    assert "Getting page http://pypi.appspot.com/INITools" not in result.stdout
    assert "Getting page http://pypi.python.org/simple/INITools" in result.stdout
Ejemplo n.º 2
0
def _test_config_file_override_stack(config_file):
    environ = clear_environ(os.environ.copy())
    environ['PIP_CONFIG_FILE'] = config_file  # set this to make pip load it
    reset_env(environ)
    write_file(
        config_file,
        textwrap.dedent("""\
        [global]
        index-url = http://download.zope.org/ppix
        """))
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Getting page http://download.zope.org/ppix/INITools" in result.stdout
    reset_env(environ)
    write_file(
        config_file,
        textwrap.dedent("""\
        [global]
        index-url = http://download.zope.org/ppix
        [install]
        index-url = http://pypi.appspot.com/
        """))
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
    result = run_pip('install',
                     '-vvv',
                     '--index-url',
                     'http://pypi.python.org/simple',
                     'INITools',
                     expect_error=True)
    assert "Getting page http://download.zope.org/ppix/INITools" not in result.stdout
    assert "Getting page http://pypi.appspot.com/INITools" not in result.stdout
    assert "Getting page http://pypi.python.org/simple/INITools" in result.stdout
Ejemplo n.º 3
0
def _test_config_file_override_stack(config_file):
    environ = clear_environ(os.environ.copy())
    environ["PIP_CONFIG_FILE"] = config_file  # set this to make pip load it
    reset_env(environ)
    write_file(
        config_file,
        textwrap.dedent(
            """\
        [global]
        index-url = http://download.zope.org/ppix
        """
        ),
    )
    result = run_pip("install", "-vvv", "INITools", expect_error=True)
    assert "Getting page http://download.zope.org/ppix/INITools" in result.stdout
    reset_env(environ)
    write_file(
        config_file,
        textwrap.dedent(
            """\
        [global]
        index-url = http://download.zope.org/ppix
        [install]
        index-url = http://pypi.appspot.com/
        """
        ),
    )
    result = run_pip("install", "-vvv", "INITools", expect_error=True)
    assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
    result = run_pip("install", "-vvv", "--index-url", "http://pypi.python.org/simple", "INITools", expect_error=True)
    assert "Getting page http://download.zope.org/ppix/INITools" not in result.stdout
    assert "Getting page http://pypi.appspot.com/INITools" not in result.stdout
    assert "Getting page http://pypi.python.org/simple/INITools" in result.stdout
Ejemplo n.º 4
0
def test_options_from_env_vars():
    """
    Test if ConfigOptionParser reads env vars (e.g. not using PyPI here)
    
    """
    environ = clear_environ(os.environ.copy())
    environ['PIP_NO_INDEX'] = '1'
    reset_env(environ)
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Ignoring indexes:" in result.stdout, str(result)
    assert "DistributionNotFound: No distributions at all found for INITools" in result.stdout
Ejemplo n.º 5
0
def test_options_from_env_vars():
    """
    Test if ConfigOptionParser reads env vars (e.g. not using PyPI here)

    """
    environ = clear_environ(os.environ.copy())
    environ['PIP_NO_INDEX'] = '1'
    reset_env(environ)
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Ignoring indexes:" in result.stdout, str(result)
    assert "DistributionNotFound: No distributions at all found for INITools" in result.stdout
Ejemplo n.º 6
0
def test_command_line_appends_correctly():
    """
    Test multiple appending options set by environmental variables.

    """
    environ = clear_environ(os.environ.copy())
    environ["PIP_FIND_LINKS"] = "http://pypi.pinaxproject.com http://example.com"
    reset_env(environ)
    result = run_pip("install", "-vvv", "INITools", expect_error=True)
    print result.stdout
    assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
    assert "Analyzing links from page http://example.com" in result.stdout
Ejemplo n.º 7
0
def test_command_line_appends_correctly():
    """
    Test multiple appending options set by environmental variables.

    """
    environ = clear_environ(os.environ.copy())
    environ[
        'PIP_FIND_LINKS'] = 'http://pypi.pinaxproject.com http://example.com'
    reset_env(environ)
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    print result.stdout
    assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
    assert "Analyzing links from page http://example.com" in result.stdout
Ejemplo n.º 8
0
def test_command_line_append_flags():
    """
    Test command line flags that append to defaults set by environmental variables.
    
    """
    environ = clear_environ(os.environ.copy())
    environ['PIP_FIND_LINKS'] = 'http://pypi.pinaxproject.com'
    reset_env(environ)
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
    reset_env(environ)
    result = run_pip('install', '-vvv', '--find-links', 'http://example.com', 'INITools', expect_error=True)
    assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
    assert "Analyzing links from page http://example.com" in result.stdout
Ejemplo n.º 9
0
def test_command_line_options_override_env_vars():
    """
    Test that command line options override environmental variables.
    
    """
    environ = clear_environ(os.environ.copy())
    environ['PIP_INDEX_URL'] = 'http://pypi.appspot.com/'
    reset_env(environ)
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
    reset_env(environ)
    result = run_pip('install', '-vvv', '--index-url', 'http://download.zope.org/ppix', 'INITools', expect_error=True)
    assert "http://pypi.appspot.com/INITools" not in result.stdout
    assert "Getting page http://download.zope.org/ppix" in result.stdout
Ejemplo n.º 10
0
def test_command_line_append_flags():
    """
    Test command line flags that append to defaults set by environmental variables.

    """
    environ = clear_environ(os.environ.copy())
    environ['PIP_FIND_LINKS'] = 'http://pypi.pinaxproject.com'
    reset_env(environ)
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
    reset_env(environ)
    result = run_pip('install',
                     '-vvv',
                     '--find-links',
                     'http://example.com',
                     'INITools',
                     expect_error=True)
    assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout
    assert "Analyzing links from page http://example.com" in result.stdout
Ejemplo n.º 11
0
def test_command_line_options_override_env_vars():
    """
    Test that command line options override environmental variables.

    """
    environ = clear_environ(os.environ.copy())
    environ['PIP_INDEX_URL'] = 'http://pypi.appspot.com/'
    reset_env(environ)
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)
    assert "Getting page http://pypi.appspot.com/INITools" in result.stdout
    reset_env(environ)
    result = run_pip('install',
                     '-vvv',
                     '--index-url',
                     'http://download.zope.org/ppix',
                     'INITools',
                     expect_error=True)
    assert "http://pypi.appspot.com/INITools" not in result.stdout
    assert "Getting page http://download.zope.org/ppix" in result.stdout