1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Address more review comments by @pradyunsg.

This commit is contained in:
Chris Jerdonek 2018-08-19 00:43:38 -07:00
parent 54b81e3a5c
commit b39bbba5e3

View file

@ -10,18 +10,20 @@ from tests.lib.git_submodule_helpers import (
from tests.lib.local_repos import local_checkout
def _checkout_into_temp(url_info, temp_dir, egg=None):
def _github_checkout(url_path, temp_dir, egg=None, scheme=None):
"""
Call local_checkout() with a GitHub URL, and return the resulting URL.
Args:
url_info: a pair of strings (scheme, url_path) to create a package URL
by completing the format string "git+{}://github.com/{}".
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".
"""
scheme, url_path = url_info
if scheme is None:
scheme = 'https'
url = 'git+{}://github.com/{}'.format(scheme, url_path)
local_url = local_checkout(url, temp_dir.join('cache'))
if egg is not None:
@ -100,8 +102,8 @@ def test_install_editable_from_git_with_https(script, tmpdir):
"""
Test cloning from Git with https.
"""
url_info = ('https', 'pypa/pip-test-package.git')
local_url = _checkout_into_temp(url_info, tmpdir, egg='pip-test-package')
url_path = 'pypa/pip-test-package.git'
local_url = _github_checkout(url_path, tmpdir, egg='pip-test-package')
result = script.pip('install', '-e', local_url, expect_error=True)
result.assert_installed('pip-test-package', with_files=['.git'])
@ -244,12 +246,12 @@ def test_git_with_tag_name_and_update(script, tmpdir):
"""
Test cloning a git repository and updating to a different version.
"""
url_info = ('https', 'pypa/pip-test-package.git')
local_url = _checkout_into_temp(url_info, tmpdir, egg='pip-test-package')
url_path = 'pypa/pip-test-package.git'
local_url = _github_checkout(url_path, tmpdir, egg='pip-test-package')
result = script.pip('install', '-e', local_url, expect_error=True)
result.assert_installed('pip-test-package', with_files=['.git'])
new_local_url = _checkout_into_temp(url_info, tmpdir)
new_local_url = _github_checkout(url_path, tmpdir)
new_local_url += '@0.1.2#egg=pip-test-package'
result = script.pip(
'install', '--global-option=--version', '-e', new_local_url,
@ -264,8 +266,8 @@ def test_git_branch_should_not_be_changed(script, tmpdir):
Editable installations should not change branch
related to issue #32 and #161
"""
url_info = ('https', 'pypa/pip-test-package.git')
local_url = _checkout_into_temp(url_info, tmpdir, egg='pip-test-package')
url_path = 'pypa/pip-test-package.git'
local_url = _github_checkout(url_path, tmpdir, egg='pip-test-package')
script.pip('install', '-e', local_url, expect_error=True)
source_dir = script.venv_path / 'src' / 'pip-test-package'
result = script.run('git', 'branch', cwd=source_dir)
@ -278,8 +280,7 @@ def test_git_with_non_editable_unpacking(script, tmpdir):
Test cloning a git repository from a non-editable URL with a given tag.
"""
url_path = 'pypa/pip-test-package.git@0.1.2#egg=pip-test-package'
url_info = ('https', url_path)
local_url = _checkout_into_temp(url_info, tmpdir)
local_url = _github_checkout(url_path, tmpdir)
result = script.pip(
'install', '--global-option=--version', local_url, expect_error=True,
)
@ -292,8 +293,10 @@ 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
"""
url_info = ('git', 'dcramer/django-devserver.git')
local_url = _checkout_into_temp(url_info, tmpdir, egg='django-devserver')
url_path = 'dcramer/django-devserver.git'
local_url = _github_checkout(
url_path, tmpdir, egg='django-devserver', scheme='git',
)
result = script.pip('install', '-e', local_url)
result.assert_installed('django-devserver', with_files=['.git'])
@ -304,8 +307,10 @@ 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
"""
url_info = ('git', 'dcramer/django-devserver.git')
local_url = _checkout_into_temp(url_info, tmpdir, egg='django-devserver')
url_path = 'dcramer/django-devserver.git'
local_url = _github_checkout(
url_path, tmpdir, egg='django-devserver', scheme='git',
)
result = script.pip('install', local_url)
devserver_folder = script.site_packages / 'devserver'
assert devserver_folder in result.files_created, str(result)