コード例 #1
0
ファイル: test_freeze.py プロジェクト: PJMODOS/pip
def test_freeze_mercurial_clone():
    """
    Test freezing a Mercurial clone.

    """
    reset_env()
    env = get_env()
    result = env.run('hg', 'clone',
                     '-r', '7bc186caa7dc',
                     local_repo('hg+http://bitbucket.org/jezdez/django-authority'),
                     'django-authority')
    result = env.run('python', 'setup.py', 'develop',
            cwd=env.scratch_path/'django-authority', expect_stderr=True)
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze
        -- stdout: --------------------
        -e %s@...#egg=django_authority-...
        ...""" % local_checkout('hg+http://bitbucket.org/jezdez/django-authority'))
    _check_output(result, expected)

    result = run_pip('freeze', '-f',
                     '%s#egg=django_authority' % local_checkout('hg+http://bitbucket.org/jezdez/django-authority'),
                     expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze -f %(repo)s#egg=django_authority
        -- stdout: --------------------
        -f %(repo)s#egg=django_authority
        -e %(repo)s@...#egg=django_authority-dev
        ...""" % {'repo': local_checkout('hg+http://bitbucket.org/jezdez/django-authority')})
    _check_output(result, expected)
コード例 #2
0
ファイル: test_uninstall.py プロジェクト: AndreaCrotti/pip
def _test_uninstall_editable_with_source_outside_venv(tmpdir):
    env = reset_env()
    result = env.run('git', 'clone', local_repo('git+git://github.com/pypa/virtualenv'), tmpdir)
    result2 = run_pip('install', '-e', tmpdir)
    assert (join(env.site_packages, 'virtualenv.egg-link') in result2.files_created), list(result2.files_created.keys())
    result3 = run_pip('uninstall', '-y', 'virtualenv', expect_error=True)
    assert_all_changes(result, result3, [env.venv/'build'])
コード例 #3
0
ファイル: test_freeze.py プロジェクト: OldBao/pip
def test_freeze_git_clone():
    """
    Test freezing a Git clone.

    """
    env = reset_env()
    result = env.run('git', 'clone', local_repo('git+http://github.com/pypa/pip-test-package.git'), 'pip-test-package')
    result = env.run('git', 'checkout', '7d654e66c8fa7149c165ddeffa5b56bc06619458',
            cwd=env.scratch_path / 'pip-test-package', expect_stderr=True)
    result = env.run('python', 'setup.py', 'develop',
            cwd=env.scratch_path / 'pip-test-package')
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze
        -- stdout: --------------------
        ...-e %s@...#egg=pip_test_package-...
        ...""" % local_checkout('git+http://github.com/pypa/pip-test-package.git'))
    _check_output(result, expected)

    result = run_pip('freeze', '-f',
                     '%s#egg=pip_test_package' % local_checkout('git+http://github.com/pypa/pip-test-package.git'),
                     expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: pip freeze -f %(repo)s#egg=pip_test_package
        -- stdout: --------------------
        -f %(repo)s#egg=pip_test_package...
        -e %(repo)s@...#egg=pip_test_package-dev
        ...""" % {'repo': local_checkout('git+http://github.com/pypa/pip-test-package.git')})
    _check_output(result, expected)
コード例 #4
0
ファイル: test_basic.py プロジェクト: saxix/pip
def test_install_with_pax_header():
    """
    test installing from a tarball with pax header for python<2.6
    """
    reset_env()
    run_from = abspath(join(here, 'packages'))
    run_pip('install', 'paxpkg.tar.bz2', cwd=run_from)
コード例 #5
0
ファイル: test_user_site.py プロジェクト: OldBao/pip
    def test_install_user_conflict_in_globalsite_and_usersite(self):
        """
        Test user install with conflict in globalsite and usersite ignores global site and updates usersite.
        """

        # the test framework only supports testing using virtualenvs.
        # the sys.path ordering for virtualenvs with --system-site-packages is this: virtualenv-site, user-site, global-site.
        # this test will use 2 modifications to simulate the user-site/global-site relationship
        # 1) a monkey patch which will make it appear INITools==0.2 is not in in the virtualenv site
        #    if we don't patch this, pip will return an installation error:  "Will not install to the usersite because it will lack sys.path precedence..."
        # 2) adding usersite to PYTHONPATH, so usersite as sys.path precedence over the virtualenv site

        env = reset_env(system_site_packages=True, sitecustomize=patch_dist_in_site_packages)
        env.environ["PYTHONPATH"] = env.root_path / env.user_site

        result1 = run_pip('install', 'INITools==0.2')
        result2 = run_pip('install', '--user', 'INITools==0.3')
        result3 = run_pip('install', '--user', 'INITools==0.1')

        #usersite has 0.1
        egg_info_folder = env.user_site / 'INITools-0.1-py%s.egg-info' % pyversion
        initools_v3_file = env.root_path / env.user_site / 'initools' / 'configparser.py'  #file only in 0.3
        assert egg_info_folder in result3.files_created, str(result3)
        assert not isfile(initools_v3_file), initools_v3_file

        #site still has 0.2 (can't just look in result1; have to check)
        egg_info_folder = env.root_path / env.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion
        initools_folder = env.root_path / env.site_packages / 'initools'
        assert isdir(egg_info_folder)
        assert isdir(initools_folder)
コード例 #6
0
ファイル: test_freeze.py プロジェクト: OldBao/pip
def test_freeze_with_requirement_option():
    """
    Test that new requirements are created correctly with --requirement hints

    """
    reset_env()
    ignores = textwrap.dedent("""\
        # Unchanged requirements below this line
        -r ignore.txt
        --requirement ignore.txt
        -Z ignore
        --always-unzip ignore
        -f http://ignore
        -i http://ignore
        --extra-index-url http://ignore
        --find-links http://ignore
        --index-url http://ignore
        """)
    write_file('hint.txt', textwrap.dedent("""\
        INITools==0.1
        NoExist==4.2
        """) + ignores)
    result = run_pip('install', 'initools==0.2')
    result = run_pip('install', 'MarkupSafe')
    result = run_pip('freeze', '--requirement', 'hint.txt', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: pip freeze --requirement hint.txt
        -- stderr: --------------------
        Requirement file contains NoExist==4.2, but that package is not installed

        -- stdout: --------------------
        INITools==0.2
        """) + ignores + "## The following requirements were added by pip --freeze:..."
    _check_output(result, expected)
コード例 #7
0
ファイル: test_uninstall.py プロジェクト: AndreaCrotti/pip
def test_uninstall_from_reqs_file():
    """
    Test uninstall from a requirements file.

    """
    env = reset_env()
    write_file('test-req.txt', textwrap.dedent("""\
        -e %s#egg=initools-dev
        # and something else to test out:
        PyLogo<0.4
        """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    result = run_pip('install', '-r', 'test-req.txt')
    write_file('test-req.txt', textwrap.dedent("""\
        # -f, -i, and --extra-index-url should all be ignored by uninstall
        -f http://www.example.com
        -i http://www.example.com
        --extra-index-url http://www.example.com

        -e %s#egg=initools-dev
        # and something else to test out:
        PyLogo<0.4
        """ % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    result2 = run_pip('uninstall', '-r', 'test-req.txt', '-y')
    assert_all_changes(
        result, result2, [env.venv/'build', env.venv/'src', env.scratch/'test-req.txt'])
コード例 #8
0
ファイル: test_uninstall.py プロジェクト: AndreaCrotti/pip
def test_uninstall_overlapping_package():
    """
    Uninstalling a distribution that adds modules to a pre-existing package
    should only remove those added modules, not the rest of the existing
    package.

    See: GitHub issue #355 (pip uninstall removes things it didn't install)
    """
    parent_pkg = abspath(join(here, 'packages', 'parent-0.1.tar.gz'))
    child_pkg = abspath(join(here, 'packages', 'child-0.1.tar.gz'))
    env = reset_env()
    result1 = run_pip('install', parent_pkg, expect_error=False)
    assert join(env.site_packages, 'parent') in result1.files_created, sorted(result1.files_created.keys())
    result2 = run_pip('install', child_pkg, expect_error=False)
    assert join(env.site_packages, 'child') in result2.files_created, sorted(result2.files_created.keys())
    assert normpath(join(env.site_packages, 'parent/plugins/child_plugin.py')) in result2.files_created, sorted(result2.files_created.keys())
    #the import forces the generation of __pycache__ if the version of python supports it
    env.run('python', '-c', "import parent.plugins.child_plugin, child")
    result3 = run_pip('uninstall', '-y', 'child', expect_error=False)
    assert join(env.site_packages, 'child') in result3.files_deleted, sorted(result3.files_created.keys())
    assert normpath(join(env.site_packages, 'parent/plugins/child_plugin.py')) in result3.files_deleted, sorted(result3.files_deleted.keys())
    assert join(env.site_packages, 'parent') not in result3.files_deleted, sorted(result3.files_deleted.keys())
    # Additional check: uninstalling 'child' should return things to the
    # previous state, without unintended side effects.
    assert_all_changes(result2, result3, [])
コード例 #9
0
ファイル: test_freeze.py プロジェクト: PJMODOS/pip
def test_freeze_with_local_option():
    """
    Test that wsgiref (from global site-packages) is reported normally, but not with --local.

    """
    reset_env()
    result = run_pip('install', 'initools==0.2')
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze
        -- stdout: --------------------
        INITools==0.2
        wsgiref==...
        <BLANKLINE>""")

    # The following check is broken (see
    # http://bitbucket.org/ianb/pip/issue/110).  For now we are simply
    # neutering this test, but if we can't find a way to fix it,
    # this whole function should be removed.

    # _check_output(result, expected)

    result = run_pip('freeze', '--local', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze --local
        -- stdout: --------------------
        INITools==0.2
        <BLANKLINE>""")
    _check_output(result, expected)
コード例 #10
0
ファイル: test_uninstall.py プロジェクト: rafaelcaricio/pip
def _test_uninstall_editable_with_source_outside_venv(tmpdir):
    env = reset_env()
    result = env.run("git", "clone", local_repo("git+git://github.com/pypa/virtualenv"), tmpdir)
    result2 = run_pip("install", "-e", tmpdir)
    assert join(env.site_packages, "virtualenv.egg-link") in result2.files_created, list(result2.files_created.keys())
    result3 = run_pip("uninstall", "-y", "virtualenv", expect_error=True)
    assert_all_changes(result, result3, [env.venv / "build"])
コード例 #11
0
def test_no_upgrade_editable_if_uncommitted_change():
    """
    No upgrade of editable if there are uncommitted local changes.

    """
    env = reset_env()

    local_url = local_checkout('git+http://github.com/prezi/sb-test-package.git')

    args = ['install',
        # older version
        '-e', '%[email protected]#egg=sb-test-package' % local_url]

    result = run_pip(*args, **{"expect_error": True})
    result.assert_installed('sb-test-package')

    # Make modification to an existing file
    with open(os.path.join(env.venv_path, 'src/sb-test-package', 'requirements.txt'), 'a') as file:
        file.write('local modification!') 

    # Attempt to install a new version
    args = ['install',
        # unpinned newer version
        '-e', '%s#egg=sb-test-package' % local_url]
    result = run_pip(*args, **{"expect_error": True})
    assert versions.__InstallationErrorMessage__ in result.stdout
コード例 #12
0
ファイル: test_freeze.py プロジェクト: PJMODOS/pip
def test_freeze_git_clone():
    """
    Test freezing a Git clone.

    """
    env = reset_env()
    result = env.run('git', 'clone', local_repo('git+http://github.com/jezdez/django-pagination.git'), 'django-pagination')
    result = env.run('git', 'checkout', '1df6507872d73ee387eb375428eafbfc253dfcd8',
            cwd=env.scratch_path/'django-pagination', expect_stderr=True)
    result = env.run('python', 'setup.py', 'develop',
            cwd=env.scratch_path / 'django-pagination')
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze
        -- stdout: --------------------
        -e %s@...#egg=django_pagination-...
        ...""" % local_checkout('git+http://github.com/jezdez/django-pagination.git'))
    _check_output(result, expected)

    result = run_pip('freeze', '-f',
                     '%s#egg=django_pagination' % local_checkout('git+http://github.com/jezdez/django-pagination.git'),
                     expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: pip freeze -f %(repo)s#egg=django_pagination
        -- stdout: --------------------
        -f %(repo)s#egg=django_pagination
        -e %(repo)s@...#egg=django_pagination-dev
        ...""" % {'repo': local_checkout('git+http://github.com/jezdez/django-pagination.git')})
    _check_output(result, expected)
コード例 #13
0
ファイル: test_config.py プロジェクト: MatthewMaker/pip
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
コード例 #14
0
def test_no_upgrade_editable_if_prefer_pinned():
    """
    No upgrade of editable if 1)--prefer-pinned-revision is True and 2) previously installed version is pinned.

    """
    reset_env()

    local_url = local_checkout('git+http://github.com/prezi/sb-test-package.git')

    args = ['install',
        # older version
        '-e', '%[email protected]#egg=sb-test-package' % local_url]

    result = run_pip(*args, **{"expect_error": True})
    result.assert_installed('sb-test-package')

    args = ['install',
        '--prefer-pinned-revision',
        # unpinned newer version
        '-e', '%s#egg=sb-test-package' % local_url]
    result = run_pip(*args, **{"expect_error": True})

    # worrysome_files_created are all files that aren't located in .git/, created by the comparison `git fetch`
    expected_files_regex = re.compile('[.]git')
    worrysome_files_created = [file_path for file_path in result.files_created.keys() if not expected_files_regex.search(file_path)]

    assert not worrysome_files_created, 'sb install sb-test-package upgraded when it should not have'
コード例 #15
0
def test_upgrade_editable_if_no_prefer_pinned():
    """
    Upgrade editable if 1)--prefer-pinned-revision is False (default) and 2) previously installed version is pinned and not the latest version.

    """
    reset_env()

    local_url = local_checkout('git+http://github.com/prezi/sb-test-package.git')

    args = ['install',
        # older version
        '-e', '%[email protected]#egg=sb-test-package' % local_url]

    result = run_pip(*args, **{"expect_error": True})
    result.assert_installed('sb-test-package')

    args = ['install',
        # unpinned newer version
        '-e', '%s#egg=sb-test-package' % local_url]
    result = run_pip(*args, **{"expect_error": True})

    # worrysome_files_created are all files that aren't located in .git/, created by the comparison `git fetch`
    expected_files_regex = re.compile('[.]git')
    new_files_created = [file_path for file_path in result.files_created.keys() if not expected_files_regex.search(file_path)]

    # new_files_created should contain a file that appears in versions >=0.2.1, but not in 0.2.2
    assert new_files_created, 'sb install sb-test-package did not upgrade when it should have'
コード例 #16
0
ファイル: test_freeze.py プロジェクト: PJMODOS/pip
def test_freeze_bazaar_clone():
    """
    Test freezing a Bazaar clone.

    """
    reset_env()
    env = get_env()
    result = env.run('bzr', 'checkout', '-r', '174',
                     local_repo('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
                     'django-wikiapp')
    result = env.run('python', 'setup.py', 'develop',
            cwd=env.scratch_path/'django-wikiapp')
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze
        -- stdout: --------------------
        -e %s@...#egg=django_wikiapp-...
        ...""" % local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'))
    _check_output(result, expected)

    result = run_pip('freeze', '-f',
                     '%s/#egg=django-wikiapp' %
                     local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
                     expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze -f %(repo)s/#egg=django-wikiapp
        -- stdout: --------------------
        -f %(repo)s/#egg=django-wikiapp
        -e %(repo)s@...#egg=django_wikiapp-...
        ...""" % {'repo':
                  local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1')})
    _check_output(result, expected)
コード例 #17
0
def test_no_upgrade_editable_if_uncommitted_new_file():
    """
    No upgrade of editable if there are uncommitted local changes.

    """
    env = reset_env()

    local_url = local_checkout('git+http://github.com/prezi/sb-test-package.git')

    args = ['install',
        # older version
        '-e', '%[email protected]#egg=sb-test-package' % local_url]

    result = run_pip(*args, **{"expect_error": True})
    result.assert_installed('sb-test-package')

    # Create a new file that isn't in source control
    subprocess.Popen(['touch', 'new_file.txt'], cwd=os.path.join(env.venv_path, 'src/sb-test-package'), stdout=subprocess.PIPE)

    # Attempt to install a new version
    args = ['install',
        # unpinned newer version
        '-e', '%s#egg=sb-test-package' % local_url]
    result = run_pip(*args, **{"expect_error": True})
    assert versions.__InstallationErrorMessage__ in result.stdout
コード例 #18
0
def test_find_links_relative_path():
    """Test find-links as a relative path."""
    e = reset_env()
    result = run_pip('install',
                     'parent==0.1',
                     '--no-index',
                     '--find-links',
                     'packages/',
                     cwd=here)
    egg_info_folder = e.site_packages / 'parent-0.1-py%s.egg-info' % pyversion
    initools_folder = e.site_packages / 'parent'
    assert egg_info_folder in result.files_created, str(result)
    assert initools_folder in result.files_created, str(result)
コード例 #19
0
ファイル: test_basic.py プロジェクト: ericholscher/pip-1
def test_vcs_url_final_slash_normalization():
    """
    Test that presence or absence of final slash in VCS URL is normalized.
    """
    reset_env()
    result = run_pip(
        'install',
        '-e',
        '%s/#egg=django-registration' % local_checkout(
            'hg+http://bitbucket.org/ubernostrum/django-registration'),
        expect_error=True)
    assert 'pip-log.txt' not in result.files_created, result.files_created[
        'pip-log.txt'].bytes
コード例 #20
0
def test_uninstall_rollback():
    """
    Test uninstall-rollback (using test package with a setup.py
    crafted to fail on install).

    """
    env = reset_env()
    find_links = 'file://' + join(here, 'packages')
    result = run_pip('install', '-f', find_links, '--no-index', 'broken==0.1')
    assert env.site_packages / 'broken.py' in result.files_created, list(
        result.files_created.keys())
    result2 = run_pip('install',
                      '-f',
                      find_links,
                      '--no-index',
                      'broken==0.2broken',
                      expect_error=True)
    assert result2.returncode == 1, str(result2)
    assert env.run('python', '-c',
                   "import broken; print(broken.VERSION)").stdout == '0.1\n'
    assert_all_changes(result.files_after, result2,
                       [env.venv / 'build', 'pip-log.txt'])
コード例 #21
0
ファイル: test_config.py プロジェクト: genome-vendor/flow-pip
def test_command_line_appends_correctly():
    """
    Test multiple appending options set by environmental variables.

    """
    environ = clear_environ(os.environ.copy())
    find_links = path_to_url(os.path.join(here, 'packages'))
    environ['PIP_FIND_LINKS'] = 'http://pypi.pinaxproject.com %s' % find_links
    reset_env(environ)
    result = run_pip('install', '-vvv', 'INITools', expect_error=True)

    assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout, result.stdout
    assert "Skipping link %s" % find_links in result.stdout
コード例 #22
0
def test_install_using_install_option_and_editable():
    """
    Test installing a tool using -e and --install-option
    """
    env = reset_env()
    folder = 'script_folder'
    mkdir(folder)
    url = 'git+git://github.com/pypa/virtualenv'
    result = run_pip('install', '-e', '%s#egg=virtualenv' %
                      local_checkout(url),
                     '--install-option=--script-dir=%s' % folder)
    virtualenv_bin = env.venv/'src'/'virtualenv'/folder/'virtualenv'+env.exe
    assert virtualenv_bin in result.files_created
コード例 #23
0
def test_install_requirements_with_env_processed_recursive():
    """
    Test requirements-ENV.txt is installed from repository if ENV is set and exists.
    """
    reset_env()
    args = ['install']
    args.extend(['--env', 'local', '-e',
                 '%s#egg=sb-test-package' %
                 local_checkout('git+http://github.com/prezi/sb-test-package.git')])
    result = run_pip(*args, **{"expect_error": True})
    result.assert_installed('sb-test-package', with_files=['.git'])
    # requirements-local.txt references 0.1.1 of pip-test-package
    assert 'Adding pip-test-package 0.1.1' in result.stdout
コード例 #24
0
def test_install_requirements_txt_processed():
    """
    Test requirements.txt is installed from repository.
    Note that we only test git, since that's all we use.
    """
    reset_env()
    args = ['install']
    args.extend(['-e',
                 '%s#egg=sb-test-package' %
                 local_checkout('git+http://github.com/prezi/sb-test-package.git')])
    result = run_pip(*args, **{"expect_error": True})
    result.assert_installed('sb-test-package', with_files=['.git'])
    result.assert_installed('pip-test-package', with_files=['.git'])
コード例 #25
0
ファイル: test_basic.py プロジェクト: ericholscher/pip-1
def test_install_editable_from_bazaar():
    """
    Test checking out from Bazaar.
    """
    reset_env()
    result = run_pip(
        'install',
        '-e',
        '%s/@174#egg=django-wikiapp' % local_checkout(
            'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'
        ),
        expect_error=True)
    result.assert_installed('django-wikiapp', with_files=['.bzr'])
コード例 #26
0
def test_relative_requirements_file():
    """
    Test installing from a requirements file with a relative path with an egg= definition..

    """
    url = path_to_url(os.path.join(here, 'packages', '..', 'packages', 'FSPkg')) + '#egg=FSPkg'
    env = reset_env()
    write_file('file-egg-req.txt', textwrap.dedent("""\
        %s
        """ % url))
    result = run_pip('install', '-vvv', '-r', env.scratch_path / 'file-egg-req.txt')
    assert (env.site_packages/'FSPkg-0.1dev-py%s.egg-info' % pyversion) in result.files_created, str(result)
    assert (env.site_packages/'fspkg') in result.files_created, str(result.stdout)
コード例 #27
0
ファイル: test_basic.py プロジェクト: ericholscher/pip-1
def test_install_editable_from_git():
    """
    Test cloning from Git.
    """
    reset_env()
    args = ['install']
    args.extend([
        '-e',
        '%s#egg=pip-test-package' %
        local_checkout('git+http://github.com/pypa/pip-test-package.git')
    ])
    result = run_pip(*args, **{"expect_error": True})
    result.assert_installed('pip-test-package', with_files=['.git'])
コード例 #28
0
def test_install_editable_from_git():
    """
    Test cloning from Git.
    """
    reset_env()
    args = ['install']
    args.extend([
        '-e',
        '%s#egg=django-feedutil' %
        local_checkout('git+http://github.com/jezdez/django-feedutil.git')
    ])
    result = run_pip(*args, **{"expect_error": True})
    result.assert_installed('django-feedutil', with_files=['.git'])
コード例 #29
0
ファイル: test_vcs_backends.py プロジェクト: qiemem/pip
def test_git_with_non_editable_unpacking():
    """
    Test cloning a git repository from a non-editable URL with a given tag.
    """
    reset_env()
    result = run_pip(
        'install',
        '--global-option=--version',
        local_checkout(
            'git+http://github.com/jezdez/[email protected]#egg=django-staticfiles'
        ),
        expect_error=True)
    assert '0.3.1\n' in result.stdout
コード例 #30
0
def test_cleanup_after_create_bundle():
    """
    Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/.

    """
    env = reset_env()
    # Install an editable to create a src/ dir.
    args = ['install']
    args.extend([
        '-e',
        '%s#egg=django-feedutil' %
        local_checkout('git+http://github.com/jezdez/django-feedutil.git')
    ])
    run_pip(*args)
    build = env.venv_path / "build"
    src = env.venv_path / "src"
    assert not exists(build), "build/ dir still exists: %s" % build
    assert exists(src), "expected src/ dir doesn't exist: %s" % src

    # Make the bundle.
    fspkg = 'file://%s/FSPkg' % join(here, 'packages')
    pkg_lines = textwrap.dedent(
        '''\
            -e %s
            -e %s#egg=initools-dev
            pip''' %
        (fspkg,
         local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')))
    write_file('bundle-req.txt', pkg_lines)
    run_pip('bundle', '-r', 'bundle-req.txt', 'test.pybundle')
    build_bundle = env.scratch_path / "build-bundle"
    src_bundle = env.scratch_path / "src-bundle"
    assert not exists(
        build_bundle), "build-bundle/ dir still exists: %s" % build_bundle
    assert not exists(
        src_bundle), "src-bundle/ dir still exists: %s" % src_bundle

    # Make sure previously created src/ from editable still exists
    assert exists(src), "expected src dir doesn't exist: %s" % src
コード例 #31
0
ファイル: test_uninstall.py プロジェクト: ericholscher/pip-1
def test_uninstall_easy_installed_console_scripts():
    """
    Test uninstalling package with console_scripts that is easy_installed.

    """
    env = reset_env()
    args = ['easy_install']
    args.append('discover')
    result = env.run(*args, **{"expect_stderr": True})
    assert env.bin / 'discover' + env.exe in result.files_created, sorted(
        result.files_created.keys())
    result2 = run_pip('uninstall', 'discover', '-y')
    assert_all_changes(result, result2, [env.venv / 'build', 'cache'])
コード例 #32
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)

    assert "Analyzing links from page http://pypi.pinaxproject.com" in result.stdout, result.stdout
    assert "Analyzing links from page http://example.com" in result.stdout, result.stdout
コード例 #33
0
ファイル: test_freeze.py プロジェクト: ericholscher/pip-1
def test_freeze_with_requirement_option():
    """
    Test that new requirements are created correctly with --requirement hints

    """
    reset_env()
    ignores = textwrap.dedent("""\
        # Unchanged requirements below this line
        -r ignore.txt
        --requirement ignore.txt
        -Z ignore
        --always-unzip ignore
        -f http://ignore
        -i http://ignore
        --extra-index-url http://ignore
        --find-links http://ignore
        --index-url http://ignore
        """)
    write_file(
        'hint.txt',
        textwrap.dedent("""\
        INITools==0.1
        NoExist==4.2
        """) + ignores)
    result = run_pip('install', 'initools==0.2')
    result = run_pip('install', 'MarkupSafe')
    result = run_pip('freeze', '--requirement', 'hint.txt', expect_stderr=True)
    expected = textwrap.dedent(
        """\
        Script result: pip freeze --requirement hint.txt
        -- stderr: --------------------
        Requirement file contains NoExist==4.2, but that package is not installed

        -- stdout: --------------------
        INITools==0.2
        """
    ) + ignores + "## The following requirements were added by pip --freeze:..."
    _check_output(result, expected)
コード例 #34
0
ファイル: test_show.py プロジェクト: genome-vendor/flow-pip
def test_show():
    """
    Test end to end test for show command.

    """
    reset_env()
    result = run_pip('show', 'pip')
    lines = result.stdout.split('\n')
    assert len(lines) == 6
    assert lines[0] == '---', lines[0]
    assert lines[1] == 'Name: pip', lines[1]
    assert lines[2] == 'Version: %s' % __version__, lines[2]
    assert lines[3].startswith('Location: '), lines[3]
    assert lines[4] == 'Requires: '
コード例 #35
0
ファイル: test_basic.py プロジェクト: qiemem/pip
def test_install_curdir_usersite_fails_in_old_python():
    """
    Test --user option on older Python versions (pre 2.6) fails intelligibly
    """
    if sys.version_info >= (2, 6):
        raise SkipTest()
    reset_env()
    run_from = abspath(join(here, 'packages', 'FSPkg'))
    result = run_pip('install',
                     '--user',
                     curdir,
                     cwd=run_from,
                     expect_error=True)
    assert '--user is only supported in Python version 2.6 and newer' in result.stdout
コード例 #36
0
ファイル: test_basic.py プロジェクト: qiemem/pip
def test_vcs_url_urlquote_normalization():
    """
    Test that urlquoted characters are normalized for repo URL comparison.
    """
    reset_env()
    result = run_pip(
        'install',
        '-e',
        '%s/#egg=django-wikiapp' % local_checkout(
            'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'
        ),
        expect_error=True)
    assert 'pip-log.txt' not in result.files_created, result.files_created[
        'pip-log.txt'].bytes
コード例 #37
0
    def test_uninstall_editable_from_usersite(self):
        """
        Test uninstall editable local user install
        """
        env = reset_env(use_distribute=True, system_site_packages=True)

        #install
        to_install = abspath(join(here, 'packages', 'FSPkg'))
        result1 = run_pip('install',
                          '--user',
                          '-e',
                          to_install,
                          expect_error=False)
        egg_link = env.user_site / 'FSPkg.egg-link'
        assert egg_link in result1.files_created, str(result1.stdout)

        #uninstall
        result2 = run_pip('uninstall', '-y', 'FSPkg')
        assert not isfile(env.root_path / egg_link)

        assert_all_changes(
            result1, result2,
            [env.venv / 'build', 'cache', env.user_site / 'easy-install.pth'])
コード例 #38
0
def test_git_with_editable_with_no_requirements_for_env():
    """
    Snakebasket should revert to using requirements.txt if --env is specified but
    requirements-ENV.txt is not found.
    """
    reset_env()
    args = ['install']
    args.extend(['--env', 'badenv', '-e',
                 '%s#egg=sb-test-package' %
                 local_checkout('git+http://github.com/prezi/sb-test-package.git')])
    result = run_pip(*args, **{"expect_error": True})
    result.assert_installed('sb-test-package', with_files=['.git'])
    # requirements.txt references 0.1.2 of pip-test-package
    assert 'Adding pip-test-package 0.1.2' in result.stdout
コード例 #39
0
def test_no_install_and_download_should_not_leave_build_dir():
    """
    It should remove build/ dir if it was pip that created
    """
    env = reset_env()
    mkdir('downloaded_packages')
    assert not os.path.exists(env.venv_path / '/build')
    result = run_pip('install', '--no-install', 'INITools==0.2', '-d',
                     'downloaded_packages')
    assert Path(
        'scratch'
    ) / 'downloaded_packages/build' not in result.files_created, 'pip should not leave build/ dir'
    assert not os.path.exists(
        env.venv_path / '/build'), "build/ dir should be deleted"
コード例 #40
0
ファイル: test_config.py プロジェクト: genome-vendor/flow-pip
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
コード例 #41
0
def test_git_with_ambiguous_revs():
    """
    Test git with two "names" (tag/branch) pointing to the same commit
    """
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    package_url = 'git+file://%[email protected]#egg=version_pkg' % (
        version_pkg_path.abspath.replace('\\', '/'))
    env.run('git', 'tag', '0.1', cwd=version_pkg_path)
    result = run_pip('install', '-e', package_url)
    assert 'Could not find a tag or branch' not in result.stdout
    # it is 'version-pkg' instead of 'version_pkg' because
    # egg-link name is version-pkg.egg-link because it is a single .py module
    result.assert_installed('version-pkg', with_files=['.git'])
コード例 #42
0
def test_no_upgrade_editable_if_prefer_pinned():
    """
    No upgrade of editable if 1)--prefer-pinned-revision is True and 2) previously installed version is pinned.

    """
    reset_env()

    local_url = local_checkout(
        'git+http://github.com/prezi/sb-test-package.git')

    args = [
        'install',
        # older version
        '-e',
        '%[email protected]#egg=sb-test-package' % local_url
    ]

    result = run_pip(*args, **{"expect_error": True})
    result.assert_installed('sb-test-package')

    args = [
        'install',
        '--prefer-pinned-revision',
        # unpinned newer version
        '-e',
        '%s#egg=sb-test-package' % local_url
    ]
    result = run_pip(*args, **{"expect_error": True})

    # worrysome_files_created are all files that aren't located in .git/, created by the comparison `git fetch`
    expected_files_regex = re.compile('[.]git')
    worrysome_files_created = [
        file_path for file_path in result.files_created.keys()
        if not expected_files_regex.search(file_path)
    ]

    assert not worrysome_files_created, 'sb install sb-test-package upgraded when it should not have'
コード例 #43
0
def test_upgrade_editable_if_no_prefer_pinned():
    """
    Upgrade editable if 1)--prefer-pinned-revision is False (default) and 2) previously installed version is pinned and not the latest version.

    """
    reset_env()

    local_url = local_checkout(
        'git+http://github.com/prezi/sb-test-package.git')

    args = [
        'install',
        # older version
        '-e',
        '%[email protected]#egg=sb-test-package' % local_url
    ]

    result = run_pip(*args, **{"expect_error": True})
    result.assert_installed('sb-test-package')

    args = [
        'install',
        # unpinned newer version
        '-e',
        '%s#egg=sb-test-package' % local_url
    ]
    result = run_pip(*args, **{"expect_error": True})

    # worrysome_files_created are all files that aren't located in .git/, created by the comparison `git fetch`
    expected_files_regex = re.compile('[.]git')
    new_files_created = [
        file_path for file_path in result.files_created.keys()
        if not expected_files_regex.search(file_path)
    ]

    # new_files_created should contain a file that appears in versions >=0.2.1, but not in 0.2.2
    assert new_files_created, 'sb install sb-test-package did not upgrade when it should have'
コード例 #44
0
ファイル: test_basic.py プロジェクト: qiemem/pip
def test_install_curdir():
    """
    Test installing current directory ('.').
    """
    env = reset_env()
    run_from = abspath(join(here, 'packages', 'FSPkg'))
    # Python 2.4 Windows balks if this exists already
    egg_info = join(run_from, "FSPkg.egg-info")
    if os.path.isdir(egg_info):
        rmtree(egg_info)
    result = run_pip('install', curdir, cwd=run_from, expect_error=False)
    fspkg_folder = env.site_packages / 'fspkg'
    egg_info_folder = env.site_packages / 'FSPkg-0.1dev-py%s.egg-info' % pyversion
    assert fspkg_folder in result.files_created, str(result.stdout)
    assert egg_info_folder in result.files_created, str(result)
コード例 #45
0
ファイル: test_uninstall.py プロジェクト: ericholscher/pip-1
def test_uninstall_overlapping_package():
    """
    Uninstalling a distribution that adds modules to a pre-existing package
    should only remove those added modules, not the rest of the existing
    package.

    See: GitHub issue #355 (pip uninstall removes things it didn't install)
    """
    parent_pkg = abspath(join(here, 'packages', 'parent-0.1.tar.gz'))
    child_pkg = abspath(join(here, 'packages', 'child-0.1.tar.gz'))
    env = reset_env()
    result1 = run_pip('install', parent_pkg, expect_error=False)
    assert join(env.site_packages, 'parent') in result1.files_created, sorted(
        result1.files_created.keys())
    result2 = run_pip('install', child_pkg, expect_error=False)
    assert join(env.site_packages, 'child') in result2.files_created, sorted(
        result2.files_created.keys())
    assert normpath(join(
        env.site_packages,
        'parent/plugins/child_plugin.py')) in result2.files_created, sorted(
            result2.files_created.keys())
    #the import forces the generation of __pycache__ if the version of python supports it
    env.run('python', '-c', "import parent.plugins.child_plugin, child")
    result3 = run_pip('uninstall', '-y', 'child', expect_error=False)
    assert join(env.site_packages, 'child') in result3.files_deleted, sorted(
        result3.files_created.keys())
    assert normpath(join(
        env.site_packages,
        'parent/plugins/child_plugin.py')) in result3.files_deleted, sorted(
            result3.files_deleted.keys())
    assert join(env.site_packages,
                'parent') not in result3.files_deleted, sorted(
                    result3.files_deleted.keys())
    # Additional check: uninstalling 'child' should return things to the
    # previous state, without unintended side effects.
    assert_all_changes(result2, result3, [])
コード例 #46
0
ファイル: test_basic.py プロジェクト: genome-vendor/flow-pip
def test_install_package_with_root():
    """
    Test installing a package using pip install --root
    """
    env = reset_env()
    root_dir = env.scratch_path / 'root'
    find_links = path_to_url(os.path.join(here, 'packages'))
    result = run_pip('install', '--root', root_dir, '-f', find_links,
                     '--no-index', 'simple==1.0')
    normal_install_path = env.root_path / env.site_packages / 'simple-1.0-py%s.egg-info' % pyversion
    #use distutils to change the root exactly how the --root option does it
    from distutils.util import change_root
    root_path = change_root(os.path.join(env.scratch, 'root'),
                            normal_install_path)
    assert root_path in result.files_created, str(result)
コード例 #47
0
def test_debian_egg_name_workaround():
    """
    We can uninstall packages installed with the pyversion removed from the
    egg-info metadata directory name.

    Refs:
    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=618367
    https://bugs.launchpad.net/ubuntu/+source/distribute/+bug/725178
    https://bitbucket.org/ianb/pip/issue/104/pip-uninstall-on-ubuntu-linux

    """
    env = reset_env()
    result = run_pip('install', 'INITools==0.2', expect_error=True)

    egg_info = os.path.join(env.site_packages,
                            "INITools-0.2-py%s.egg-info" % pyversion)

    # Debian only removes pyversion for global installs, not inside a venv
    # so even if this test runs on a Debian/Ubuntu system with broken setuptools,
    # since our test runs inside a venv we'll still have the normal .egg-info
    assert egg_info in result.files_created, "Couldn't find %s" % egg_info

    # The Debian no-pyversion version of the .egg-info
    mangled = os.path.join(env.site_packages, "INITools-0.2.egg-info")
    assert mangled not in result.files_created, "Found unexpected %s" % mangled

    # Simulate a Debian install by copying the .egg-info to their name for it
    full_egg_info = os.path.join(env.root_path, egg_info)
    assert os.path.isdir(full_egg_info)
    full_mangled = os.path.join(env.root_path, mangled)
    os.renames(full_egg_info, full_mangled)
    assert os.path.isdir(full_mangled)

    # Try the uninstall and verify that everything is removed.
    result2 = run_pip("uninstall", "INITools", "-y")
    assert_all_changes(result, result2, [env.venv / 'build', 'cache'])