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:
parent
54b81e3a5c
commit
b39bbba5e3
1 changed files with 22 additions and 17 deletions
|
@ -10,18 +10,20 @@ from tests.lib.git_submodule_helpers import (
|
||||||
from tests.lib.local_repos import local_checkout
|
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.
|
Call local_checkout() with a GitHub URL, and return the resulting URL.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
url_info: a pair of strings (scheme, url_path) to create a package URL
|
url_path: the string used to create the package URL by filling in the
|
||||||
by completing the format string "git+{}://github.com/{}".
|
format string "git+{scheme}://github.com/{url_path}".
|
||||||
temp_dir: the pytest tmpdir value.
|
temp_dir: the pytest tmpdir value.
|
||||||
egg: an optional project name to append to the URL as the egg fragment,
|
egg: an optional project name to append to the URL as the egg fragment,
|
||||||
prior to returning.
|
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)
|
url = 'git+{}://github.com/{}'.format(scheme, url_path)
|
||||||
local_url = local_checkout(url, temp_dir.join('cache'))
|
local_url = local_checkout(url, temp_dir.join('cache'))
|
||||||
if egg is not None:
|
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.
|
Test cloning from Git with https.
|
||||||
"""
|
"""
|
||||||
url_info = ('https', 'pypa/pip-test-package.git')
|
url_path = 'pypa/pip-test-package.git'
|
||||||
local_url = _checkout_into_temp(url_info, tmpdir, egg='pip-test-package')
|
local_url = _github_checkout(url_path, tmpdir, egg='pip-test-package')
|
||||||
result = script.pip('install', '-e', local_url, expect_error=True)
|
result = script.pip('install', '-e', local_url, expect_error=True)
|
||||||
result.assert_installed('pip-test-package', with_files=['.git'])
|
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.
|
Test cloning a git repository and updating to a different version.
|
||||||
"""
|
"""
|
||||||
url_info = ('https', 'pypa/pip-test-package.git')
|
url_path = 'pypa/pip-test-package.git'
|
||||||
local_url = _checkout_into_temp(url_info, tmpdir, egg='pip-test-package')
|
local_url = _github_checkout(url_path, tmpdir, egg='pip-test-package')
|
||||||
result = script.pip('install', '-e', local_url, expect_error=True)
|
result = script.pip('install', '-e', local_url, expect_error=True)
|
||||||
result.assert_installed('pip-test-package', with_files=['.git'])
|
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'
|
new_local_url += '@0.1.2#egg=pip-test-package'
|
||||||
result = script.pip(
|
result = script.pip(
|
||||||
'install', '--global-option=--version', '-e', new_local_url,
|
'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
|
Editable installations should not change branch
|
||||||
related to issue #32 and #161
|
related to issue #32 and #161
|
||||||
"""
|
"""
|
||||||
url_info = ('https', 'pypa/pip-test-package.git')
|
url_path = 'pypa/pip-test-package.git'
|
||||||
local_url = _checkout_into_temp(url_info, tmpdir, egg='pip-test-package')
|
local_url = _github_checkout(url_path, tmpdir, egg='pip-test-package')
|
||||||
script.pip('install', '-e', local_url, expect_error=True)
|
script.pip('install', '-e', local_url, expect_error=True)
|
||||||
source_dir = script.venv_path / 'src' / 'pip-test-package'
|
source_dir = script.venv_path / 'src' / 'pip-test-package'
|
||||||
result = script.run('git', 'branch', cwd=source_dir)
|
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.
|
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_path = 'pypa/pip-test-package.git@0.1.2#egg=pip-test-package'
|
||||||
url_info = ('https', url_path)
|
local_url = _github_checkout(url_path, tmpdir)
|
||||||
local_url = _checkout_into_temp(url_info, tmpdir)
|
|
||||||
result = script.pip(
|
result = script.pip(
|
||||||
'install', '--global-option=--version', local_url, expect_error=True,
|
'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"
|
Test cloning a git repository from an editable url which contains "dev"
|
||||||
string
|
string
|
||||||
"""
|
"""
|
||||||
url_info = ('git', 'dcramer/django-devserver.git')
|
url_path = 'dcramer/django-devserver.git'
|
||||||
local_url = _checkout_into_temp(url_info, tmpdir, egg='django-devserver')
|
local_url = _github_checkout(
|
||||||
|
url_path, tmpdir, egg='django-devserver', scheme='git',
|
||||||
|
)
|
||||||
result = script.pip('install', '-e', local_url)
|
result = script.pip('install', '-e', local_url)
|
||||||
result.assert_installed('django-devserver', with_files=['.git'])
|
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"
|
Test cloning a git repository from a non-editable url which contains "dev"
|
||||||
string
|
string
|
||||||
"""
|
"""
|
||||||
url_info = ('git', 'dcramer/django-devserver.git')
|
url_path = 'dcramer/django-devserver.git'
|
||||||
local_url = _checkout_into_temp(url_info, tmpdir, egg='django-devserver')
|
local_url = _github_checkout(
|
||||||
|
url_path, tmpdir, egg='django-devserver', scheme='git',
|
||||||
|
)
|
||||||
result = script.pip('install', local_url)
|
result = script.pip('install', local_url)
|
||||||
devserver_folder = script.site_packages / 'devserver'
|
devserver_folder = script.site_packages / 'devserver'
|
||||||
assert devserver_folder in result.files_created, str(result)
|
assert devserver_folder in result.files_created, str(result)
|
||||||
|
|
Loading…
Reference in a new issue