Ejemplo n.º 1
0
def test_git_with_tag_name_and_update(script, tmpdir):
    """
    Test cloning a git repository and updating to a different version.
    """
    result = script.pip(
        'install',
        '-e',
        '%s#egg=pip-test-package' % local_checkout(
            'git+http://github.com/pypa/pip-test-package.git',
            tmpdir.join("cache"),
        ),
        expect_error=True,
    )
    result.assert_installed('pip-test-package', with_files=['.git'])
    result = script.pip(
        'install',
        '--global-option=--version',
        '-e',
        '%[email protected]#egg=pip-test-package' % local_checkout(
            'git+http://github.com/pypa/pip-test-package.git',
            tmpdir.join("cache"),
        ),
        expect_error=True,
    )
    assert '0.1.2' in result.stdout
Ejemplo n.º 2
0
def test_cleanup_after_create_bundle(script, tmpdir, data):
    """
    Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/.

    """
    # 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', tmpdir.join("cache"))])
    script.pip(*args)
    build = script.venv_path/"build"
    src = script.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 = path_to_url(data.packages/'FSPkg')
    pkg_lines = textwrap.dedent('''\
            -e %s
            -e %s#egg=initools-dev
            pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache"))))
    script.scratch_path.join("bundle-req.txt").write(pkg_lines)
    script.pip('bundle', '-r', 'bundle-req.txt', 'test.pybundle')
    build_bundle = script.scratch_path/"build-bundle"
    src_bundle = script.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
    script.assert_no_temp()

    # Make sure previously created src/ from editable still exists
    assert exists(src), "expected src dir doesn't exist: %s" % src
Ejemplo n.º 3
0
def test_cleanup_after_create_bundle(script, tmpdir, data):
    """
    Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/.

    """
    # 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', tmpdir.join("cache"))])
    script.pip(*args)
    build = script.venv_path/"build"
    src = script.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 = path_to_url(data.packages/'FSPkg')
    pkg_lines = textwrap.dedent('''\
            -e %s
            -e %s#egg=initools-dev
            pip''' % (fspkg, local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache"))))
    script.scratch_path.join("bundle-req.txt").write(pkg_lines)
    script.pip('bundle', '--no-use-wheel', '-r', 'bundle-req.txt', 'test.pybundle')
    build_bundle = script.scratch_path/"build-bundle"
    src_bundle = script.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
    script.assert_no_temp()

    # Make sure previously created src/ from editable still exists
    assert exists(src), "expected src dir doesn't exist: %s" % src
Ejemplo n.º 4
0
def test_uninstall_from_reqs_file(script, tmpdir):
    """
    Test uninstall from a requirements file.

    """
    script.scratch_path.join("test-req.txt").write(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', tmpdir.join("cache"))))
    result = script.pip('install', '-r', 'test-req.txt')
    script.scratch_path.join("test-req.txt").write(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', tmpdir.join("cache"))))
    result2 = script.pip('uninstall', '-r', 'test-req.txt', '-y')
    assert_all_changes(
        result, result2, [script.venv/'build', script.venv/'src', script.scratch/'test-req.txt',
        script.site_packages/'easy-install.pth'])
Ejemplo n.º 5
0
def test_freeze_git_clone(script, tmpdir):
    """
    Test freezing a Git clone.

    """
    result = script.run('git', 'clone', local_repo('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")), 'pip-test-package', expect_stderr=True)
    result = script.run('git', 'checkout', '7d654e66c8fa7149c165ddeffa5b56bc06619458',
            cwd=script.scratch_path / 'pip-test-package', expect_stderr=True)
    result = script.run('python', 'setup.py', 'develop',
            cwd=script.scratch_path / 'pip-test-package')
    result = script.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', tmpdir.join("cache")))
    _check_output(result, expected)

    result = script.pip('freeze', '-f',
                     '%s#egg=pip_test_package' % local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")),
                     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-0.1.1
        ...""" % {'repo': local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache"))})
    _check_output(result, expected)
Ejemplo n.º 6
0
def test_editable_no_install_followed_by_no_download(script, tmpdir):
    """
    Test installing an editable in two steps (first with --no-install, then
    with --no-download).
    """
    result = script.pip(
        'install',
        '-e',
        '%s#egg=initools-dev' % local_checkout(
            'svn+http://svn.colorstudy.com/INITools/trunk',
            tmpdir.join("cache"),
        ),
        '--no-install',
        expect_error=True,
    )
    result.assert_installed(
        'INITools',
        without_egg_link=True,
        with_files=['.svn'],
    )

    result = script.pip(
        'install',
        '-e',
        '%s#egg=initools-dev' % local_checkout(
            'svn+http://svn.colorstudy.com/INITools/trunk',
            tmpdir.join("cache"),
        ),
        '--no-download',
        expect_error=True,
    )
    result.assert_installed('INITools', without_files=[curdir, '.svn'])
Ejemplo n.º 7
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'])
Ejemplo n.º 8
0
def test_freeze_mercurial_clone(script, tmpdir):
    """
    Test freezing a Mercurial clone.

    """
    result = script.run(
        'hg',
        'clone',
        '-r',
        'c9963c111e7c',
        local_repo(
            'hg+http://bitbucket.org/pypa/pip-test-package',
            tmpdir.join("cache"),
        ),
        'pip-test-package',
    )
    result = script.run(
        'python',
        'setup.py',
        'develop',
        cwd=script.scratch_path / 'pip-test-package',
        expect_stderr=True,
    )
    result = script.pip('freeze', expect_stderr=True)
    expected = textwrap.dedent(
        """
            Script result: ...pip freeze
            -- stdout: --------------------
            ...-e %s@...#egg=pip_test_package-...
            ...
        """ % local_checkout(
            'hg+http://bitbucket.org/pypa/pip-test-package',
            tmpdir.join("cache"),
        ), ).strip()
    _check_output(result, expected)

    result = script.pip(
        'freeze',
        '-f',
        '%s#egg=pip_test_package' % local_checkout(
            'hg+http://bitbucket.org/pypa/pip-test-package',
            tmpdir.join("cache"),
        ),
        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(
                'hg+http://bitbucket.org/pypa/pip-test-package',
                tmpdir.join("cache"),
            ),
        }, ).strip()
    _check_output(result, expected)
Ejemplo n.º 9
0
def test_editable_no_install_followed_by_no_download(script, tmpdir):
    """
    Test installing an editable in two steps (first with --no-install, then
    with --no-download).
    """
    result = script.pip(
        'install',
        '-e',
        '%s#egg=initools-dev' %
        local_checkout(
            'svn+http://svn.colorstudy.com/INITools/trunk',
            tmpdir.join("cache"),
        ),
        '--no-install',
        expect_error=True,
    )
    result.assert_installed(
        'INITools', without_egg_link=True, with_files=['.svn'],
    )

    result = script.pip(
        'install',
        '-e',
        '%s#egg=initools-dev' %
        local_checkout(
            'svn+http://svn.colorstudy.com/INITools/trunk',
            tmpdir.join("cache"),
        ),
        '--no-download',
        expect_error=True,
    )
    result.assert_installed('INITools', without_files=[curdir, '.svn'])
Ejemplo n.º 10
0
def test_freeze_mercurial_clone(script, tmpdir):
    """
    Test freezing a Mercurial clone.

    """
    result = script.run('hg', 'clone',
                     '-r', 'c9963c111e7c',
                     local_repo('hg+http://bitbucket.org/pypa/pip-test-package', tmpdir.join("cache")),
                     'pip-test-package')
    result = script.run('python', 'setup.py', 'develop',
            cwd=script.scratch_path/'pip-test-package', expect_stderr=True)
    result = script.pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: ...pip freeze
        -- stdout: --------------------
        ...-e %s@...#egg=pip_test_package-...
        ...""" % local_checkout('hg+http://bitbucket.org/pypa/pip-test-package', tmpdir.join("cache")))
    _check_output(result, expected)

    result = script.pip('freeze', '-f',
                     '%s#egg=pip_test_package' % local_checkout('hg+http://bitbucket.org/pypa/pip-test-package', tmpdir.join("cache")),
                     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('hg+http://bitbucket.org/pypa/pip-test-package', tmpdir.join("cache"))})
    _check_output(result, expected)
Ejemplo n.º 11
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(tests_data, '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
    env.assert_no_temp()

    # Make sure previously created src/ from editable still exists
    assert exists(src), "expected src dir doesn't exist: %s" % src
Ejemplo n.º 12
0
def test_uninstall_from_reqs_file(script, tmpdir):
    """
    Test uninstall from a requirements file.

    """
    script.scratch_path.join("test-req.txt").write(
        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',
                             tmpdir.join("cache"))))
    result = script.pip('install', '-r', 'test-req.txt')
    script.scratch_path.join("test-req.txt").write(
        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',
                             tmpdir.join("cache"))))
    result2 = script.pip('uninstall', '-r', 'test-req.txt', '-y')
    assert_all_changes(result, result2, [
        script.venv / 'build', script.venv / 'src', script.scratch /
        'test-req.txt', script.site_packages / 'easy-install.pth'
    ])
Ejemplo n.º 13
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'])
Ejemplo n.º 14
0
def test_git_with_tag_name_and_update(script, tmpdir):
    """
    Test cloning a git repository and updating to a different version.
    """
    result = script.pip('install', '-e', '%s#egg=pip-test-package' %
                     local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")),
                     expect_error=True)
    result.assert_installed('pip-test-package', with_files=['.git'])
    result = script.pip('install', '--global-option=--version', '-e',
                     '%[email protected]#egg=pip-test-package' %
                     local_checkout('git+http://github.com/pypa/pip-test-package.git', tmpdir.join("cache")),
                     expect_error=True)
    assert '0.1.2' in result.stdout
Ejemplo n.º 15
0
def test_freeze_git_clone(script, tmpdir):
    """
    Test freezing a Git clone.

    """
    result = script.run('git',
                        'clone',
                        local_repo(
                            'git+http://github.com/pypa/pip-test-package.git',
                            tmpdir.join("cache")),
                        'pip-test-package',
                        expect_stderr=True)
    result = script.run('git',
                        'checkout',
                        '7d654e66c8fa7149c165ddeffa5b56bc06619458',
                        cwd=script.scratch_path / 'pip-test-package',
                        expect_stderr=True)
    result = script.run('python',
                        'setup.py',
                        'develop',
                        cwd=script.scratch_path / 'pip-test-package')
    result = script.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',
                       tmpdir.join("cache")))
    _check_output(result, expected)

    result = script.pip(
        'freeze',
        '-f',
        '%s#egg=pip_test_package' %
        local_checkout('git+http://github.com/pypa/pip-test-package.git',
                       tmpdir.join("cache")),
        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-0.1.1
        ...""" % {
            'repo':
            local_checkout('git+http://github.com/pypa/pip-test-package.git',
                           tmpdir.join("cache"))
        })
    _check_output(result, expected)
Ejemplo n.º 16
0
def test_freeze_bazaar_clone(script, tmpdir):
    """
    Test freezing a Bazaar clone.

    """

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

    result = script.run('bzr', 'checkout', '-r', '174',
                     local_repo('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache")),
                     'django-wikiapp')
    result = script.run('python', 'setup.py', 'develop',
            cwd=script.scratch_path/'django-wikiapp')
    result = script.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 = script.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)
Ejemplo n.º 17
0
def _github_checkout(
    url_path: str,
    temp_dir: Path,
    rev: Optional[str] = None,
    egg: Optional[str] = None,
    scheme: Optional[str] = None,
) -> str:
    """
    Call local_checkout() with a GitHub URL, and return the resulting URL.

    Args:
      url_path: the string used to create the package URL by filling in the
        format string "git+{scheme}://github.com/{url_path}".
      temp_dir: the pytest tmpdir value.
      egg: an optional project name to append to the URL as the egg fragment,
        prior to returning.
      scheme: the scheme without the "git+" prefix. Defaults to "https".
    """
    if scheme is None:
        scheme = "https"
    url = f"git+{scheme}://github.com/{url_path}"
    local_url = local_checkout(url, temp_dir)
    if rev is not None:
        local_url += f"@{rev}"
    if egg is not None:
        local_url += f"#egg={egg}"

    return local_url
Ejemplo n.º 18
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)
Ejemplo n.º 19
0
def test_upgrade_vcs_req_with_no_dists_found(script, tmpdir):
    """It can upgrade a VCS requirement that has no distributions otherwise."""
    req = "%s#egg=pip-test-package" % local_checkout(
        "git+http://github.com/pypa/pip-test-package.git", tmpdir.join("cache"))
    script.pip("install", req)
    result = script.pip("install", "-U", req)
    assert not result.returncode
Ejemplo n.º 20
0
def test_git_with_editable_where_egg_contains_dev_string(script, tmpdir):
    """
    Test cloning a git repository from an editable url which contains "dev" string
    """
    result = script.pip('install', '-e', '%s#egg=django-devserver' %
                     local_checkout('git+git://github.com/dcramer/django-devserver.git', tmpdir.join("cache")))
    result.assert_installed('django-devserver', with_files=['.git'])
Ejemplo n.º 21
0
def test_freeze_svn(script, tmpdir):
    """Test freezing a svn checkout"""

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

    # Checkout
    script.run(
        'svn', 'co', '-r10',
        local_repo(
            'svn+http://svn.colorstudy.com/INITools/trunk',
            tmpdir.join("cache"),
        ),
        'initools-trunk',
    )
    # Install with develop
    script.run(
        'python', 'setup.py', 'develop',
        cwd=script.scratch_path / 'initools-trunk',
        expect_stderr=True,
    )
    result = script.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)
Ejemplo n.º 22
0
def test_download_editable_to_custom_path(script, tmpdir):
    """
    Test downloading an editable using a relative custom src folder.
    """
    script.scratch_path.join("customdl").mkdir()
    result = script.pip(
        'install',
        '-e',
        '%s#egg=initools-dev' %
        local_checkout('svn+http://svn.colorstudy.com/INITools/trunk',
                       tmpdir.join("cache")),
        '--src',
        'customsrc',
        '--download',
        'customdl',
        expect_stderr=True)
    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
    assert ('DEPRECATION: pip install --download has been deprecated and will '
            'be removed in the future. Pip now has a download command that '
            'should be used instead.') in result.stderr
Ejemplo n.º 23
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
Ejemplo n.º 24
0
def test_multiple_requirements_files(script: PipTestEnvironment, tmpdir: Path) -> None:
    """
    Test installing from multiple nested requirements files.

    """
    other_lib_name, other_lib_version = "six", "1.16.0"
    script.scratch_path.joinpath("initools-req.txt").write_text(
        textwrap.dedent(
            """
            -e {}@10#egg=INITools
            -r {}-req.txt
        """
        ).format(
            local_checkout("svn+http://svn.colorstudy.com/INITools", tmpdir),
            other_lib_name,
        ),
    )
    script.scratch_path.joinpath(f"{other_lib_name}-req.txt").write_text(
        f"{other_lib_name}<={other_lib_version}"
    )
    result = script.pip("install", "-r", script.scratch_path / "initools-req.txt")
    assert result.files_created[script.site_packages / other_lib_name].dir
    fn = f"{other_lib_name}-{other_lib_version}.dist-info"
    assert result.files_created[script.site_packages / fn].dir
    result.did_create(script.venv / "src" / "initools")
def test_freeze_svn(script, tmpdir):
    """Test freezing a svn checkout"""

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

    # Checkout
    script.run(
        'svn', 'co', '-r10',
        local_repo(
            'svn+http://svn.colorstudy.com/INITools/trunk',
            tmpdir.join("cache"),
        ),
        'initools-trunk',
    )
    # Install with develop
    script.run(
        'python', 'setup.py', 'develop',
        cwd=script.scratch_path / 'initools-trunk',
        expect_stderr=True,
    )
    result = script.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)
Ejemplo n.º 26
0
def test_multiple_requirements_files(script, tmpdir):
    """
    Test installing from multiple nested requirements files.

    """
    other_lib_name, other_lib_version = 'anyjson', '0.3'
    script.scratch_path.joinpath("initools-req.txt").write_text(
        textwrap.dedent("""
            -e {}@10#egg=INITools
            -r {}-req.txt
        """).format
        (
            local_checkout('svn+http://svn.colorstudy.com/INITools', tmpdir),
            other_lib_name
        ),
    )
    script.scratch_path.joinpath(
        "{other_lib_name}-req.txt".format(**locals())).write_text(
            "{other_lib_name}<={other_lib_version}".format(**locals())
    )
    result = script.pip(
        'install', '-r', script.scratch_path / 'initools-req.txt'
    )
    assert result.files_created[script.site_packages / other_lib_name].dir
    fn = '{other_lib_name}-{other_lib_version}-py{pyversion}.egg-info'.format(
        pyversion=pyversion, **locals())
    assert result.files_created[script.site_packages / fn].dir
    result.did_create(script.venv / 'src' / 'initools')
Ejemplo n.º 27
0
def test_download_editable_to_custom_path(script, tmpdir):
    """
    Test downloading an editable using a relative custom src folder.
    """
    script.scratch_path.join("customdl").mkdir()
    result = script.pip(
        'install',
        '-e',
        '%s#egg=initools-dev' %
        local_checkout(
            'svn+http://svn.colorstudy.com/INITools/trunk',
            tmpdir.join("cache")
        ),
        '--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
Ejemplo n.º 28
0
def test_download_editable_to_custom_path(script, tmpdir):
    """
    Test downloading an editable using a relative custom src folder.
    """
    script.scratch_path.join("customdl").mkdir()
    result = script.pip(
        'install',
        '-e',
        '%s#egg=initools-dev' %
        local_checkout('svn+http://svn.colorstudy.com/INITools/trunk',
                       tmpdir.join("cache")),
        '--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
Ejemplo n.º 29
0
def test_multiple_requirements_files(script, tmpdir):
    """
    Test installing from multiple nested requirements files.

    """
    other_lib_name, other_lib_version = 'anyjson', '0.3'
    script.scratch_path.join("initools-req.txt").write(
        textwrap.dedent("""
            -e %s@10#egg=INITools-dev
            -r %s-req.txt
        """) %
        (
            local_checkout(
                'svn+http://svn.colorstudy.com/INITools/trunk',
                tmpdir.join("cache"),
            ),
            other_lib_name
        ),
    )
    script.scratch_path.join("%s-req.txt" % other_lib_name).write(
        "%s<=%s" % (other_lib_name, other_lib_version)
    )
    result = script.pip(
        'install', '-r', script.scratch_path / 'initools-req.txt'
    )
    assert result.files_created[script.site_packages / other_lib_name].dir
    fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion)
    assert result.files_created[script.site_packages / fn].dir
    assert script.venv / 'src' / 'initools' in result.files_created
Ejemplo n.º 30
0
def test_create_bundle():
    """
    Test making a bundle.  We'll grab one package from the filesystem
    (the FSPkg dummy package), one from vcs (initools) and one from an
    index (pip itself).

    """
    env = reset_env()
    fspkg = path_to_url2(Path(tests_data) / 'packages' / 'FSPkg')
    run_pip('install', '-e', fspkg)
    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)
    # Create a bundle in env.scratch_path/ test.pybundle
    result = run_pip('bundle', '-r', env.scratch_path / 'bundle-req.txt',
                     env.scratch_path / 'test.pybundle')
    bundle = result.files_after.get(join('scratch', 'test.pybundle'), None)
    assert bundle is not None

    files = zipfile.ZipFile(bundle.full).namelist()
    assert 'src/FSPkg/' in files
    assert 'src/initools/' in files
    assert 'build/pip/' in files
Ejemplo n.º 31
0
def test_multiple_requirements_files(script, tmpdir):
    """
    Test installing from multiple nested requirements files.

    """
    other_lib_name, other_lib_version = 'anyjson', '0.3'
    script.scratch_path.join("initools-req.txt").write(
        textwrap.dedent("""
            -e %s@10#egg=INITools
            -r %s-req.txt
        """) %
        (
            local_checkout(
                'svn+http://svn.colorstudy.com/INITools/trunk',
                tmpdir.join("cache"),
            ),
            other_lib_name
        ),
    )
    script.scratch_path.join("%s-req.txt" % other_lib_name).write(
        "%s<=%s" % (other_lib_name, other_lib_version)
    )
    result = script.pip(
        'install', '-r', script.scratch_path / 'initools-req.txt'
    )
    assert result.files_created[script.site_packages / other_lib_name].dir
    fn = '%s-%s-py%s.egg-info' % (other_lib_name, other_lib_version, pyversion)
    assert result.files_created[script.site_packages / fn].dir
    assert script.venv / 'src' / 'initools' in result.files_created
Ejemplo n.º 32
0
def test_git_with_non_editable_where_egg_contains_dev_string(script, tmpdir):
    """
    Test cloning a git repository from a non-editable url which contains "dev" string
    """
    result = script.pip('install', '%s#egg=django-devserver' %
                     local_checkout('git+git://github.com/dcramer/django-devserver.git', tmpdir.join("cache")))
    devserver_folder = script.site_packages/'devserver'
    assert devserver_folder in result.files_created, str(result)
Ejemplo n.º 33
0
def test_upgrade_vcs_req_with_no_dists_found(script, tmpdir):
    """It can upgrade a VCS requirement that has no distributions otherwise."""
    req = "%s#egg=pip-test-package" % local_checkout(
        "git+http://github.com/pypa/pip-test-package.git",
        tmpdir.join("cache"))
    script.pip("install", req)
    result = script.pip("install", "-U", req)
    assert not result.returncode
Ejemplo n.º 34
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
Ejemplo n.º 35
0
def test_freeze_bazaar_clone(script, tmpdir):
    """
    Test freezing a Bazaar clone.

    """

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

    result = script.run(
        'bzr',
        'checkout',
        '-r',
        '174',
        local_repo(
            'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/'
            'release-0.1',
            tmpdir.join("cache"),
        ),
        'django-wikiapp',
    )
    result = script.run(
        'python',
        'setup.py',
        'develop',
        cwd=script.scratch_path / 'django-wikiapp',
        expect_stderr=True,
    )
    result = script.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 = script.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)
Ejemplo n.º 36
0
def test_install_editable_from_git_with_https(script, tmpdir):
    """
    Test cloning from Git with https.
    """
    result = script.pip('install', '-e',
                     '%s#egg=pip-test-package' %
                     local_checkout('git+https://github.com/pypa/pip-test-package.git', tmpdir.join("cache")),
                     expect_error=True)
    result.assert_installed('pip-test-package', with_files=['.git'])
Ejemplo n.º 37
0
def test_install_global_option_using_editable(script, tmpdir):
    """
    Test using global distutils options, but in an editable installation
    """
    url = 'hg+http://bitbucket.org/runeh/anyjson'
    result = script.pip('install', '--global-option=--version',
                     '-e', '%[email protected]#egg=anyjson' %
                      local_checkout(url, tmpdir.join("cache")))
    assert '0.2.5\n' in result.stdout
Ejemplo n.º 38
0
def test_git_with_non_editable_unpacking(script, tmpdir):
    """
    Test cloning a git repository from a non-editable URL with a given tag.
    """
    result = script.pip('install', '--global-option=--version', local_checkout(
                     'git+http://github.com/pypa/[email protected]#egg=pip-test-package',
                     tmpdir.join("cache")
                     ), expect_error=True)
    assert '0.1.2' in result.stdout
Ejemplo n.º 39
0
def test_install_editable_from_bazaar(script, tmpdir):
    """
    Test checking out from Bazaar.
    """
    result = script.pip('install', '-e',
                     '%s/@174#egg=django-wikiapp' %
                     local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache")),
                     expect_error=True)
    result.assert_installed('django-wikiapp', with_files=['.bzr'])
Ejemplo n.º 40
0
def test_install_editable_from_svn(script, tmpdir):
    """
    Test checking out from svn.
    """
    result = script.pip(
        'install', '-e', '%s#egg=initools-dev' %
        local_checkout('svn+http://svn.colorstudy.com/INITools/trunk',
                       tmpdir.join("cache")))
    result.assert_installed('INITools', with_files=['.svn'])
Ejemplo n.º 41
0
def test_install_global_option_using_editable(script, tmpdir):
    """
    Test using global distutils options, but in an editable installation
    """
    url = 'hg+http://bitbucket.org/runeh/anyjson'
    result = script.pip(
        'install', '--global-option=--version', '-e',
        '%[email protected]#egg=anyjson' % local_checkout(url, tmpdir.join("cache")))
    assert '0.2.5\n' in result.stdout
Ejemplo n.º 42
0
def test_vcs_url_final_slash_normalization(script, tmpdir):
    """
    Test that presence or absence of final slash in VCS URL is normalized.
    """
    result = script.pip('install', '-e',
                     '%s/#egg=ScriptTest' %
                     local_checkout('hg+https://bitbucket.org/ianb/scripttest', tmpdir.join("cache")),
                     expect_error=True)
    assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
Ejemplo n.º 43
0
 def test_install_subversion_usersite_editable_with_distribute(self):
     """
     Test installing current directory ('.') into usersite after installing distribute
     """
     env = reset_env(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)
Ejemplo n.º 44
0
def test_vcs_url_urlquote_normalization(script, tmpdir):
    """
    Test that urlquoted characters are normalized for repo URL comparison.
    """
    result = script.pip('install', '-e',
                     '%s/#egg=django-wikiapp' %
                     local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache")),
                     expect_error=True)
    assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
Ejemplo n.º 45
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"])
Ejemplo n.º 46
0
 def test_install_subversion_usersite_editable_with_distribute(self, script, virtualenv, tmpdir):
     """
     Test installing current directory ('.') into usersite after installing distribute
     """
     virtualenv.system_site_packages = True
     result = script.pip('install', '--user', '-e',
                      '%s#egg=initools-dev' %
                      local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")))
     result.assert_installed('INITools', use_user_site=True)
Ejemplo n.º 47
0
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'])
Ejemplo n.º 48
0
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
Ejemplo n.º 49
0
 def test_install_subversion_usersite_editable_with_distribute(self):
     """
     Test installing current directory ('.') into usersite after installing distribute
     """
     env = reset_env(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)
Ejemplo n.º 50
0
def test_install_editable_from_bazaar(script, tmpdir):
    """
    Test checking out from Bazaar.
    """
    result = script.pip('install', '-e',
                     '%s/@174#egg=django-wikiapp' %
                     local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache")),
                     expect_error=True)
    result.assert_installed('django-wikiapp', with_files=['.bzr'])
Ejemplo n.º 51
0
def test_install_editable_from_svn(script, tmpdir):
    """
    Test checking out from svn.
    """
    result = script.pip('install',
                     '-e',
                     '%s#egg=initools-dev' %
                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")))
    result.assert_installed('INITools', with_files=['.svn'])
Ejemplo n.º 52
0
def test_install_editable_from_hg(script, tmpdir):
    """
    Test cloning from Mercurial.
    """
    result = script.pip('install', '-e',
                     '%s#egg=ScriptTest' %
                     local_checkout('hg+https://bitbucket.org/ianb/scripttest', tmpdir.join("cache")),
                     expect_error=True)
    result.assert_installed('ScriptTest', with_files=['.hg'])
Ejemplo n.º 53
0
def test_vcs_url_urlquote_normalization(script, tmpdir):
    """
    Test that urlquoted characters are normalized for repo URL comparison.
    """
    result = script.pip('install', '-e',
                     '%s/#egg=django-wikiapp' %
                     local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1', tmpdir.join("cache")),
                     expect_error=True)
    assert 'pip-log.txt' not in result.files_created, result.files_created['pip-log.txt'].bytes
Ejemplo n.º 54
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)
Ejemplo n.º 55
0
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'])
Ejemplo n.º 56
0
def test_uninstall_editable_from_svn(script, tmpdir):
    """
    Test uninstalling an editable installation from svn.
    """
    result = script.pip('install', '-e', '%s#egg=initools-dev' %
                     local_checkout('svn+http://svn.colorstudy.com/INITools/trunk', tmpdir.join("cache")))
    result.assert_installed('INITools')
    result2 = script.pip('uninstall', '-y', 'initools')
    assert (script.venv/'src'/'initools' in result2.files_after), 'oh noes, pip deleted my sources!'
    assert_all_changes(result, result2, [script.venv/'src', script.venv/'build', script.site_packages/'easy-install.pth'])