示例#1
0
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'])
示例#2
0
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)
示例#3
0
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)
示例#4
0
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)
示例#5
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=pip-test-package' %
                    local_checkout('git+http://github.com/pypa/pip-test-package.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
示例#6
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)
示例#7
0
def test_git_with_tag_name_and_update():
    """
    Test cloning a git repository and updating to a different version.
    """
    reset_env()
    result = run_pip('install', '-e', '%s#egg=django-staticfiles' %
                     local_checkout('git+http://github.com/jezdez/django-staticfiles.git'),
                     expect_error=True)
    result.assert_installed('django-staticfiles', with_files=['.git'])
    result = run_pip('install', '--global-option=--version', '-e',
                     '%[email protected]#egg=django-staticfiles' %
                     local_checkout('git+http://github.com/jezdez/django-staticfiles.git'),
                     expect_error=True)
    assert '0.3.1\n' in result.stdout
示例#8
0
def test_freeze_bazaar_clone():
    """
    Test freezing a Bazaar clone.

    """

    checkout_path = local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1')
    #bzr internally stores windows drives as uppercase; we'll match that.
    checkout_pathC = checkout_path.replace('c:', 'C:')

    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-...
        ...""" % checkout_pathC)
    _check_output(result, expected)

    result = run_pip('freeze', '-f',
                     '%s/#egg=django-wikiapp' % checkout_path,
                     expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze -f %(repo)s/#egg=django-wikiapp
        -- stdout: --------------------
        -f %(repo)s/#egg=django-wikiapp
        ...-e %(repoC)s@...#egg=django_wikiapp-...
        ...""" % {'repoC': checkout_pathC, 'repo': checkout_path})
    _check_output(result, expected)
示例#9
0
def test_upgrade_editable_if_ignore_untracked_files():
    """
    Upgrade editable if --ignore-untracked-files is True

    """
    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',
        '--ignore-untracked-files',
        # 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'
示例#10
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'
示例#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
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
示例#13
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'
示例#14
0
def test_upgrade_vcs_req_with_no_dists_found():
    """It can upgrade a VCS requirement that has no distributions otherwise."""
    reset_env()
    req = "%s#egg=pip-test-package" % local_checkout(
        "git+http://github.com/pypa/pip-test-package.git")
    run_pip("install", req)
    result = run_pip("install", "-U", req)
    assert not result.returncode
示例#15
0
def test_git_with_editable_where_egg_contains_dev_string():
    """
    Test cloning a git repository from an editable url which contains "dev" string
    """
    reset_env()
    result = run_pip('install', '-e', '%s#egg=django-devserver' %
                     local_checkout('git+git://github.com/dcramer/django-devserver.git'))
    result.assert_installed('django-devserver', with_files=['.git'])
def test_install_editable_from_svn():
    """
    Test checking out from svn.
    """
    reset_env()
    result = run_pip(
        "install", "-e", "%s#egg=initools-dev" % local_checkout("svn+http://svn.colorstudy.com/INITools/trunk")
    )
    result.assert_installed("INITools", with_files=[".svn"])
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"])
示例#18
0
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
示例#19
0
def test_git_with_non_editable_where_egg_contains_dev_string():
    """
    Test cloning a git repository from a non-editable url which contains "dev" string
    """
    env = reset_env()
    result = run_pip('install', '%s#egg=django-devserver' %
                     local_checkout('git+git://github.com/dcramer/django-devserver.git'))
    devserver_folder = env.site_packages/'devserver'
    assert devserver_folder in result.files_created, str(result)
示例#20
0
 def test_install_subversion_usersite_editable_with_distribute(self):
     """
     Test installing current directory ('.') into usersite after installing distribute
     """
     env = reset_env(use_distribute=True, system_site_packages=True)
     result = run_pip('install', '--user', '-e',
                      '%s#egg=initools-dev' %
                      local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))
     result.assert_installed('INITools', use_user_site=True)
示例#21
0
def test_git_with_editable_where_egg_contains_dev_string():
    """
    Test cloning a git repository from an editable url which contains "dev" string
    """
    reset_env()
    result = run_pip(
        "install", "-e", "%s#egg=django-devserver" % local_checkout("git+git://github.com/dcramer/django-devserver.git")
    )
    result.assert_installed("django-devserver", with_files=[".git"])
示例#22
0
文件: test_basic.py 项目: saxix/pip
def test_install_global_option_using_editable():
    """
    Test using global distutils options, but in an editable installation
    """
    reset_env()
    url = 'hg+http://bitbucket.org/runeh/anyjson'
    result = run_pip('install', '--global-option=--version',
                     '-e', '%[email protected]#egg=anyjson' %
                      local_checkout(url))
    assert '0.2.5\n' in result.stdout
示例#23
0
文件: test_basic.py 项目: saxix/pip
def test_editable_no_install_followed_by_no_download():
    """
    Test installing an editable in two steps (first with --no-install, then with --no-download).
    """
    reset_env()

    result = run_pip('install',
                     '-e',
                     '%s#egg=initools-dev' %
                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
                     '--no-install', expect_error=True)
    result.assert_installed('INITools', without_egg_link=True, with_files=['.svn'])

    result = run_pip('install',
                     '-e',
                     '%s#egg=initools-dev' %
                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
                     '--no-download', expect_error=True)
    result.assert_installed('INITools', without_files=[curdir, '.svn'])
示例#24
0
文件: test_basic.py 项目: saxix/pip
def test_install_editable_from_hg():
    """
    Test cloning from Mercurial.
    """
    reset_env()
    result = run_pip('install', '-e',
                     '%s#egg=django-registration' %
                     local_checkout('hg+http://bitbucket.org/ubernostrum/django-registration'),
                     expect_error=True)
    result.assert_installed('django-registration', with_files=['.hg'])
示例#25
0
文件: test_basic.py 项目: saxix/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
示例#26
0
文件: test_basic.py 项目: saxix/pip
def test_install_editable_from_svn():
    """
    Test checking out from svn.
    """
    reset_env()
    result = run_pip('install',
                     '-e',
                     '%s#egg=initools-dev' %
                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))
    result.assert_installed('INITools', with_files=['.svn'])
示例#27
0
文件: test_basic.py 项目: saxix/pip
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'])
示例#28
0
def test_install_editable_from_git_with_https():
    """
    Test cloning from Git with https.
    """
    reset_env()
    result = run_pip('install', '-e',
                     '%s#egg=django-feedutil' %
                     local_checkout('git+https://github.com/jezdez/django-feedutil.git'),
                     expect_error=True)
    result.assert_installed('django-feedutil', with_files=['.git'])
示例#29
0
文件: test_basic.py 项目: saxix/pip
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
def test_install_editable_from_git_with_https():
    """
    Test cloning from Git with https.
    """
    reset_env()
    result = run_pip('install', '-e',
                     '%s#egg=pip-test-package' %
                     local_checkout('git+https://github.com/pypa/pip-test-package.git'),
                     expect_error=True)
    result.assert_installed('pip-test-package', with_files=['.git'])
示例#31
0
 def test_install_subversion_usersite_editable_with_setuptools_fails(self):
     """
     Test installing current directory ('.') into usersite using setuptools fails
     """
     # We don't try to use setuptools for 3.X.
     if sys.version_info >= (3, ):
         raise SkipTest()
     env = reset_env(use_distribute=False, system_site_packages=True)
     result = run_pip(
         'install',
         '--user',
         '-e',
         '%s#egg=initools-dev' %
         local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
         expect_error=True)
     assert '--user --editable not supported with setuptools, use distribute' in result.stdout
示例#32
0
文件: test_basic.py 项目: qiemem/pip
def test_install_subversion_usersite_editable_with_distribute():
    """
    Test installing current directory ('.') into usersite after installing distribute
    """
    if sys.version_info < (2, 6):
        raise SkipTest()
    # FIXME distutils --user option seems to be broken in pypy
    if hasattr(sys, "pypy_version_info"):
        raise SkipTest()
    env = reset_env(use_distribute=True)
    (env.lib_path /
     'no-global-site-packages.txt').rm()  # this one reenables user_site

    result = run_pip(
        'install', '--user', '-e', '%s#egg=initools-dev' %
        local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))
    result.assert_installed('INITools', use_user_site=True)
示例#33
0
def test_upgrade_editable_if_ignore_untracked_files():
    """
    Upgrade editable if --ignore-untracked-files is True

    """
    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',
        '--ignore-untracked-files',
        # 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'
示例#34
0
def test_multiple_requirements_files():
    """
    Test installing from multiple nested requirements files.

    """
    other_lib_name, other_lib_version = 'anyjson', '0.3'
    env = reset_env()
    write_file('initools-req.txt', textwrap.dedent("""\
        -e %s@10#egg=INITools-dev
        -r %s-req.txt""" % (local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
                            other_lib_name)))
    write_file('%s-req.txt' % other_lib_name, textwrap.dedent("""\
        %s<=%s
        """ % (other_lib_name, other_lib_version)))
    result = run_pip('install', '-r', env.scratch_path / 'initools-req.txt')
    assert result.files_created[env.site_packages/other_lib_name].dir
    fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion)
    assert result.files_created[env.site_packages/fn].dir
    assert env.venv/'src'/'initools' in result.files_created
示例#35
0
文件: test_freeze.py 项目: slacy/pip
def test_freeze_svn():
    """Now lets try it with an svn checkout"""
    env = reset_env()
    result = env.run(
        'svn', 'co', '-r10',
        local_repo('svn+http://svn.colorstudy.com/INITools/trunk'),
        'initools-trunk')
    result = env.run('python',
                     'setup.py',
                     'develop',
                     cwd=env.scratch_path / 'initools-trunk')
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent(
        """\
        Script result: ...pip freeze
        -- stdout: --------------------
        -e %s@10#egg=INITools-0.3.1dev_r10-py...-dev_r10
        ...""" %
        local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))
    _check_output(result, expected)
示例#36
0
def test_requirement_set_will_include_correct_version():
    """ Out of two versions of the same package, the requirement set will contain the newer one. """
    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,
        # newer version
        '-e',
        '%[email protected]#egg=sb-test-package' % local_url
    ]
    result = run_pip(*args, **{"expect_error": True})
    result.assert_installed('sb-test-package')
    v020 = 'sb-test-package 0.2.0'
    v021 = 'sb-test-package 0.2.1'
    assert not (v020 in result.stdout)
    assert v021 in result.stdout
def test_install_subversion_usersite_editable_with_setuptools_fails():
    """
    Test installing current directory ('.') into usersite using setuptools fails
    """
    # --user only works on 2.6 or higher
    if sys.version_info < (2, 6):
        raise SkipTest()
    # We don't try to use setuptools for 3.X.
    elif sys.version_info >= (3,):
        raise SkipTest()
    env = reset_env(use_distribute=False)
    no_site_packages = env.lib_path/'no-global-site-packages.txt'
    if os.path.isfile(no_site_packages):
        no_site_packages.rm() # this re-enables user_site

    result = run_pip('install', '--user', '-e',
                     '%s#egg=initools-dev' %
                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
                     expect_error=True)
    assert '--user --editable not supported with setuptools, use distribute' in result.stdout
示例#38
0
def test_freeze_svn():
    """Test freezing a svn checkout"""

    checkout_path = local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')
    #svn internally stores windows drives as uppercase; we'll match that.
    checkout_path = checkout_path.replace('c:', 'C:')

    env = reset_env()
    result = env.run('svn', 'co', '-r10',
                     local_repo('svn+http://svn.colorstudy.com/INITools/trunk'),
                     'initools-trunk')
    result = env.run('python', 'setup.py', 'develop',
            cwd=env.scratch_path/ 'initools-trunk', expect_stderr=True)
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze
        -- stdout: --------------------
        -e %s@10#egg=INITools-0.3.1dev...-dev_r10
        ...""" % checkout_path)
    _check_output(result, expected)
示例#39
0
文件: test_basic.py 项目: qiemem/pip
def test_download_editable_to_custom_path():
    """
    Test downloading an editable using a relative custom src folder.
    """
    reset_env()
    mkdir('customdl')
    result = run_pip(
        'install', '-e', '%s#egg=initools-dev' %
        local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'),
        '--src', 'customsrc', '--download', 'customdl')
    customsrc = Path('scratch') / 'customsrc' / 'initools'
    assert customsrc in result.files_created, sorted(
        result.files_created.keys())
    assert customsrc / 'setup.py' in result.files_created, sorted(
        result.files_created.keys())

    customdl = Path('scratch') / 'customdl' / 'initools'
    customdl_files_created = [
        filename for filename in result.files_created
        if filename.startswith(customdl)
    ]
    assert customdl_files_created
示例#40
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'
示例#41
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'