Exemplo n.º 1
0
def test_reinstalling_works_with_editible_non_master_branch(script):
    """
    Reinstalling an editable installation should not assume that the "master"
    branch exists. See https://github.com/pypa/pip/issues/4448.
    """
    version_pkg_path = _create_test_package(script)

    # Switch the default branch to something other than 'master'
    script.run('git', 'branch', '-m', 'foobar', cwd=version_pkg_path)

    script.pip(
        'install', '-e',
        '%s#egg=version_pkg' %
        ('git+file://' + version_pkg_path.abspath.replace('\\', '/')),
    )
    version = script.run('version_pkg')
    assert '0.1' in version.stdout

    _change_test_package_version(script, version_pkg_path)
    script.pip(
        'install', '-e',
        '%s#egg=version_pkg' %
        ('git+file://' + version_pkg_path.abspath.replace('\\', '/')),
    )
    version = script.run('version_pkg')
    assert 'some different version' in version.stdout
Exemplo n.º 2
0
def test_git_with_tag_name_as_revision(script: PipTestEnvironment) -> None:
    """
    Git backend should be able to install from tag names
    """
    version_pkg_path = _create_test_package(script)
    script.run("git", "tag", "test_tag", cwd=version_pkg_path)
    _change_test_package_version(script, version_pkg_path)
    version = _install_version_pkg(script, version_pkg_path, rev="test_tag")
    assert "0.1" == version
Exemplo n.º 3
0
def test_git_with_sha1_revisions(script):
    """
    Git backend should be able to install from SHA1 revisions
    """
    version_pkg_path = _create_test_package(script)
    _change_test_package_version(script, version_pkg_path)
    sha1 = script.run('git', 'rev-parse', 'HEAD~1', cwd=version_pkg_path).stdout.strip()
    script.pip('install', '-e', '%s@%s#egg=version_pkg' % ('git+file://' + version_pkg_path.abspath.replace('\\', '/'), sha1))
    version = script.run('version_pkg')
    assert '0.1' in version.stdout, version.stdout
Exemplo n.º 4
0
def test_git_with_branch_name_as_revision(script: PipTestEnvironment) -> None:
    """
    Git backend should be able to install from branch names
    """
    version_pkg_path = _create_test_package(script)
    branch = "test_branch"
    script.run("git", "checkout", "-b", branch, cwd=version_pkg_path)
    _change_test_package_version(script, version_pkg_path)
    version = _install_version_pkg(script, version_pkg_path, rev=branch)
    assert "some different version" == version
Exemplo n.º 5
0
def test_git_with_tag_name_as_revision(script):
    """
    Git backend should be able to install from tag names
    """
    version_pkg_path = _create_test_package(script)
    script.run('git', 'tag', 'test_tag', expect_stderr=True, cwd=version_pkg_path)
    _change_test_package_version(script, version_pkg_path)
    script.pip('install', '-e', '%s@test_tag#egg=version_pkg' % ('git+file://' + version_pkg_path.abspath.replace('\\', '/')))
    version = script.run('version_pkg')
    assert '0.1' in version.stdout
Exemplo n.º 6
0
def test_git_with_branch_name_as_revision(script):
    """
    Git backend should be able to install from branch names
    """
    version_pkg_path = _create_test_package(script)
    script.run('git', 'checkout', '-b', 'test_branch', expect_stderr=True, cwd=version_pkg_path)
    _change_test_package_version(script, version_pkg_path)
    script.pip('install', '-e', '%s@test_branch#egg=version_pkg' % ('git+file://' + version_pkg_path.abspath.replace('\\', '/')))
    version = script.run('version_pkg')
    assert 'some different version' in version.stdout
Exemplo n.º 7
0
def test_git_install_branch_again_after_branch_changes(script):
    """
    Test installing a branch again after the branch is updated in the remote
    repository.
    """
    version_pkg_path = _create_test_package(script)
    version = _install_version_pkg(script, version_pkg_path, rev='master')
    assert version == '0.1'

    _change_test_package_version(script, version_pkg_path)
    version = _install_version_pkg(script, version_pkg_path, rev='master')
    assert version == 'some different version'
Exemplo n.º 8
0
def test_git_install_ref(script):
    """
    The Git backend should be able to install a ref with the first install.
    """
    version_pkg_path = _create_test_package(script)
    _add_ref(script, version_pkg_path, 'refs/foo/bar')
    _change_test_package_version(script, version_pkg_path)

    version = _install_version_pkg(
        script, version_pkg_path, rev='refs/foo/bar', expect_stderr=True,
    )
    assert '0.1' == version
Exemplo n.º 9
0
def test_editable_git_upgrade(script):
    """
    Test installing an editable git package from a repository, upgrading the repository,
    installing again, and check it gets the newer version
    """
    version_pkg_path = _create_test_package(script)
    script.pip('install', '-e', '%s#egg=version_pkg' % ('git+file://' + version_pkg_path))
    version = script.run('version_pkg')
    assert '0.1' in version.stdout
    _change_test_package_version(script, version_pkg_path)
    script.pip('install', '-e', '%s#egg=version_pkg' % ('git+file://' + version_pkg_path))
    version2 = script.run('version_pkg')
    assert 'some different version' in version2.stdout, "Output: %s" % (version2.stdout)
Exemplo n.º 10
0
def test_git_with_tag_name_as_revision():
    """
    Git backend should be able to install from tag names
    """
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    env.run("git", "tag", "test_tag", expect_stderr=True, cwd=version_pkg_path)
    _change_test_package_version(env, version_pkg_path)
    run_pip(
        "install", "-e", "%s@test_tag#egg=version_pkg" % ("git+file://" + version_pkg_path.abspath.replace("\\", "/"))
    )
    version = env.run("version_pkg")
    assert "0.1" in version.stdout
Exemplo n.º 11
0
def test_git_with_tag_name_as_revision(script):
    """
    Git backend should be able to install from tag names
    """
    version_pkg_path = _create_test_package(script)
    script.run(
        'git', 'tag', 'test_tag',
        expect_stderr=True,
        cwd=version_pkg_path,
    )
    _change_test_package_version(script, version_pkg_path)
    version = _install_version_pkg(script, version_pkg_path, rev='test_tag')
    assert '0.1' == version
Exemplo n.º 12
0
def test_git_with_sha1_revisions():
    """
    Git backend should be able to install from SHA1 revisions
    """
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    _change_test_package_version(env, version_pkg_path)
    sha1 = env.run("git", "rev-parse", "HEAD~1", cwd=version_pkg_path).stdout.strip()
    run_pip(
        "install", "-e", "%s@%s#egg=version_pkg" % ("git+file://" + version_pkg_path.abspath.replace("\\", "/"), sha1)
    )
    version = env.run("version_pkg")
    assert "0.1" in version.stdout, version.stdout
Exemplo n.º 13
0
def test_git_install_branch_again_after_branch_changes(
    script: PipTestEnvironment, ) -> None:
    """
    Test installing a branch again after the branch is updated in the remote
    repository.
    """
    version_pkg_path = _create_test_package(script.scratch_path)
    version = _install_version_pkg(script, version_pkg_path, rev="master")
    assert version == "0.1"

    _change_test_package_version(script, version_pkg_path)
    version = _install_version_pkg(script, version_pkg_path, rev="master")
    assert version == "some different version"
Exemplo n.º 14
0
def test_editable_git_upgrade():
    """
    Test installing an editable git package from a repository, upgrading the repository,
    installing again, and check it gets the newer version
    """
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    run_pip("install", "-e", "%s#egg=version_pkg" % ("git+file://" + version_pkg_path))
    version = env.run("version_pkg")
    assert "0.1" in version.stdout
    _change_test_package_version(env, version_pkg_path)
    run_pip("install", "-e", "%s#egg=version_pkg" % ("git+file://" + version_pkg_path))
    version2 = env.run("version_pkg")
    assert "some different version" in version2.stdout, "Output: %s" % (version2.stdout)
Exemplo n.º 15
0
def test_git_with_branch_name_as_revision(script):
    """
    Git backend should be able to install from branch names
    """
    version_pkg_path = _create_test_package(script)
    branch = 'test_branch'
    script.run(
        'git', 'checkout', '-b', branch,
        expect_stderr=True,
        cwd=version_pkg_path,
    )
    _change_test_package_version(script, version_pkg_path)
    version = _install_version_pkg(script, version_pkg_path, rev=branch)
    assert 'some different version' == version
Exemplo n.º 16
0
def test_git_with_short_sha1_revisions(script):
    """
    Git backend should be able to install from SHA1 revisions
    """
    version_pkg_path = _create_test_package(script)
    _change_test_package_version(script, version_pkg_path)
    sha1 = script.run(
        'git', 'rev-parse', 'HEAD~1',
        cwd=version_pkg_path,
    ).stdout.strip()[:7]
    version = _install_version_pkg(
        script, version_pkg_path, rev=sha1, expect_stderr=True,
    )
    assert '0.1' == version
Exemplo n.º 17
0
def test_git_with_short_sha1_revisions(script: PipTestEnvironment) -> None:
    """
    Git backend should be able to install from SHA1 revisions
    """
    version_pkg_path = _create_test_package(script)
    _change_test_package_version(script, version_pkg_path)
    sha1 = script.run(
        "git",
        "rev-parse",
        "HEAD~1",
        cwd=version_pkg_path,
    ).stdout.strip()[:7]
    version = _install_version_pkg(script, version_pkg_path, rev=sha1)
    assert "0.1" == version
Exemplo n.º 18
0
def test_git_with_branch_name_as_revision():
    """
    Git backend should be able to install from branch names
    """
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    env.run("git", "checkout", "-b", "test_branch", expect_stderr=True, cwd=version_pkg_path)
    _change_test_package_version(env, version_pkg_path)
    run_pip(
        "install",
        "-e",
        "%s@test_branch#egg=version_pkg" % ("git+file://" + version_pkg_path.abspath.replace("\\", "/")),
    )
    version = env.run("version_pkg")
    assert "some different version" in version.stdout
Exemplo n.º 19
0
def test_reinstalling_works_with_editable_non_master_branch(script):
    """
    Reinstalling an editable installation should not assume that the "master"
    branch exists. See https://github.com/pypa/pip/issues/4448.
    """
    version_pkg_path = _create_test_package(script)

    # Switch the default branch to something other than 'master'
    script.run('git', 'branch', '-m', 'foobar', cwd=version_pkg_path)

    version = _install_version_pkg(script, version_pkg_path)
    assert '0.1' == version

    _change_test_package_version(script, version_pkg_path)
    version = _install_version_pkg(script, version_pkg_path)
    assert 'some different version' == version
Exemplo n.º 20
0
def test_git_install_again_after_changes(script):
    """
    Test installing a repository a second time without specifying a revision,
    and after updates to the remote repository.

    This test also checks that no warning message like the following gets
    logged on the update: "Did not find branch or tag ..., assuming ref or
    revision."
    """
    version_pkg_path = _create_test_package(script)
    version = _install_version_pkg(script, version_pkg_path)
    assert version == '0.1'

    _change_test_package_version(script, version_pkg_path)
    version = _install_version_pkg(script, version_pkg_path)
    assert version == 'some different version'
Exemplo n.º 21
0
def test_reinstalling_works_with_editable_non_master_branch(
    script: PipTestEnvironment, ) -> None:
    """
    Reinstalling an editable installation should not assume that the "master"
    branch exists. See https://github.com/pypa/pip/issues/4448.
    """
    version_pkg_path = _create_test_package(script.scratch_path)

    # Switch the default branch to something other than 'master'
    script.run("git", "branch", "-m", "foobar", cwd=version_pkg_path)

    version = _install_version_pkg(script, version_pkg_path)
    assert "0.1" == version

    _change_test_package_version(script, version_pkg_path)
    version = _install_version_pkg(script, version_pkg_path)
    assert "some different version" == version
Exemplo n.º 22
0
def test_git_with_ref_as_revision(script):
    """
    Git backend should be able to install from a ref
    """
    version_pkg_path = _create_test_package(script)
    script.run(
        'git', 'update-ref', 'refs/foo/bar', 'HEAD',
        expect_stderr=True,
        cwd=version_pkg_path,
    )
    _change_test_package_version(script, version_pkg_path)
    script.pip(
        'install', '-e', '%s@refs/foo/bar#egg=version_pkg' %
        ('git+file://' + version_pkg_path.abspath.replace('\\', '/')),
        expect_stderr=True
    )
    version = script.run('version_pkg')
    assert '0.1' in version.stdout
Exemplo n.º 23
0
def test_git_install_then_install_ref(script):
    """
    The Git backend should be able to install a ref after a package has
    already been installed.
    """
    version_pkg_path = _create_test_package(script)
    _add_ref(script, version_pkg_path, 'refs/foo/bar')
    _change_test_package_version(script, version_pkg_path)

    version = _install_version_pkg(
        script, version_pkg_path, expect_stderr=True,
    )
    assert 'some different version' == version

    # Now install the ref.
    version = _install_version_pkg(
        script, version_pkg_path, rev='refs/foo/bar', expect_stderr=True,
    )
    assert '0.1' == version
Exemplo n.º 24
0
def test_editable__branch_with_sha_different_from_default(
    script: PipTestEnvironment, ) -> None:
    """
    Test installing in editable mode a branch whose sha is different from
    the sha of the default branch.
    """
    version_pkg_path = _create_test_package(script.scratch_path)
    # Create a second branch.
    script.run("git", "branch", "develop", cwd=version_pkg_path)
    # Add another commit to the master branch to give it a different sha.
    _change_test_package_version(script, version_pkg_path)

    version = _install_version_pkg(script, version_pkg_path, rev="develop")
    assert version == "0.1"

    branch = _get_editable_branch(script, "version-pkg")
    assert branch == "develop"

    remote = _get_branch_remote(script, "version-pkg", "develop")
    assert remote == "origin"
Exemplo n.º 25
0
def test_editable__branch_with_sha_different_from_default(script):
    """
    Test installing in editable mode a branch whose sha is different from
    the sha of the default branch.
    """
    version_pkg_path = _create_test_package(script)
    # Create a second branch.
    script.run(
        'git', 'branch', 'develop', expect_stderr=True,
        cwd=version_pkg_path,
    )
    # Add another commit to the master branch to give it a different sha.
    _change_test_package_version(script, version_pkg_path)

    version = _install_version_pkg(
        script, version_pkg_path, rev='develop', expect_stderr=True
    )
    assert version == '0.1'

    branch = _get_editable_branch(script, 'version-pkg')
    assert branch == 'develop'

    remote = _get_branch_remote(script, 'version-pkg', 'develop')
    assert remote == 'origin'