2015-01-15 00:53:15 +01:00
|
|
|
import pytest
|
|
|
|
|
2014-08-04 06:01:47 +02:00
|
|
|
from tests.lib import (_create_test_package, _change_test_package_version,
|
|
|
|
pyversion)
|
2013-05-27 19:46:31 +02:00
|
|
|
from tests.lib.local_repos import local_checkout
|
2010-11-21 19:31:15 +01:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_install_editable_from_git_with_https(script, tmpdir):
|
2010-11-05 21:24:17 +01:00
|
|
|
"""
|
|
|
|
Test cloning from Git with https.
|
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
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,
|
|
|
|
)
|
2011-09-14 00:20:06 +02:00
|
|
|
result.assert_installed('pip-test-package', with_files=['.git'])
|
2010-11-05 21:24:17 +01:00
|
|
|
|
2010-08-05 16:09:40 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2014-08-04 06:01:47 +02:00
|
|
|
def test_install_noneditable_git(script, tmpdir):
|
|
|
|
"""
|
|
|
|
Test installing from a non-editable git URL with a given tag.
|
|
|
|
"""
|
|
|
|
result = script.pip(
|
|
|
|
'install',
|
2014-08-04 06:33:28 +02:00
|
|
|
'git+https://github.com/pypa/pip-test-package.git'
|
|
|
|
'@0.1.1#egg=pip-test-package'
|
|
|
|
)
|
2014-08-04 06:01:47 +02:00
|
|
|
egg_info_folder = (
|
2014-08-04 06:33:28 +02:00
|
|
|
script.site_packages /
|
|
|
|
'pip_test_package-0.1.1-py%s.egg-info' % pyversion
|
|
|
|
)
|
|
|
|
result.assert_installed('piptestpackage',
|
|
|
|
without_egg_link=True,
|
|
|
|
editable=False)
|
2014-08-04 06:01:47 +02:00
|
|
|
assert egg_info_folder in result.files_created, str(result)
|
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_git_with_sha1_revisions(script):
|
2010-08-05 16:09:40 +02:00
|
|
|
"""
|
|
|
|
Git backend should be able to install from SHA1 revisions
|
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
version_pkg_path = _create_test_package(script)
|
|
|
|
_change_test_package_version(script, version_pkg_path)
|
2014-01-28 15:17:51 +01:00
|
|
|
sha1 = script.run(
|
|
|
|
'git', 'rev-parse', 'HEAD~1',
|
|
|
|
cwd=version_pkg_path,
|
|
|
|
).stdout.strip()
|
|
|
|
script.pip(
|
|
|
|
'install', '-e',
|
|
|
|
'%s@%s#egg=version_pkg' %
|
2015-03-16 13:34:52 +01:00
|
|
|
('git+file://' + version_pkg_path.abspath.replace('\\', '/'), sha1),
|
|
|
|
expect_stderr=True
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2013-08-21 11:16:07 +02:00
|
|
|
version = script.run('version_pkg')
|
2010-08-05 16:09:40 +02:00
|
|
|
assert '0.1' in version.stdout, version.stdout
|
|
|
|
|
2010-08-05 16:35:05 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_git_with_branch_name_as_revision(script):
|
2010-08-05 16:35:05 +02:00
|
|
|
"""
|
|
|
|
Git backend should be able to install from branch names
|
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
version_pkg_path = _create_test_package(script)
|
2014-01-28 15:17:51 +01:00
|
|
|
script.run(
|
|
|
|
'git', 'checkout', '-b', 'test_branch',
|
|
|
|
expect_stderr=True,
|
|
|
|
cwd=version_pkg_path,
|
|
|
|
)
|
2013-08-21 11:16:07 +02:00
|
|
|
_change_test_package_version(script, version_pkg_path)
|
2014-01-28 15:17:51 +01:00
|
|
|
script.pip(
|
|
|
|
'install', '-e', '%s@test_branch#egg=version_pkg' %
|
|
|
|
('git+file://' + version_pkg_path.abspath.replace('\\', '/'))
|
|
|
|
)
|
2013-08-21 11:16:07 +02:00
|
|
|
version = script.run('version_pkg')
|
2010-08-05 16:35:05 +02:00
|
|
|
assert 'some different version' in version.stdout
|
|
|
|
|
2010-08-19 15:39:50 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_git_with_tag_name_as_revision(script):
|
2010-08-05 16:35:05 +02:00
|
|
|
"""
|
|
|
|
Git backend should be able to install from tag names
|
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
version_pkg_path = _create_test_package(script)
|
2014-01-28 15:17:51 +01:00
|
|
|
script.run(
|
|
|
|
'git', 'tag', 'test_tag',
|
|
|
|
expect_stderr=True,
|
|
|
|
cwd=version_pkg_path,
|
|
|
|
)
|
2013-08-21 11:16:07 +02:00
|
|
|
_change_test_package_version(script, version_pkg_path)
|
2014-01-28 15:17:51 +01:00
|
|
|
script.pip(
|
|
|
|
'install', '-e', '%s@test_tag#egg=version_pkg' %
|
|
|
|
('git+file://' + version_pkg_path.abspath.replace('\\', '/'))
|
|
|
|
)
|
2013-08-21 11:16:07 +02:00
|
|
|
version = script.run('version_pkg')
|
2010-08-05 16:35:05 +02:00
|
|
|
assert '0.1' in version.stdout
|
|
|
|
|
2010-11-20 19:44:08 +01:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_git_with_tag_name_and_update(script, tmpdir):
|
2010-11-20 19:44:08 +01:00
|
|
|
"""
|
|
|
|
Test cloning a git repository and updating to a different version.
|
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
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,
|
|
|
|
)
|
2011-09-14 00:20:06 +02:00
|
|
|
result.assert_installed('pip-test-package', with_files=['.git'])
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '--global-option=--version', '-e',
|
|
|
|
'%s@0.1.2#egg=pip-test-package' %
|
|
|
|
local_checkout(
|
|
|
|
'git+http://github.com/pypa/pip-test-package.git',
|
|
|
|
tmpdir.join("cache"),
|
|
|
|
),
|
|
|
|
expect_error=True,
|
|
|
|
)
|
2012-06-03 00:30:45 +02:00
|
|
|
assert '0.1.2' in result.stdout
|
2010-11-20 19:44:08 +01:00
|
|
|
|
2010-11-21 19:31:15 +01:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_git_branch_should_not_be_changed(script, tmpdir):
|
2010-11-21 19:31:15 +01:00
|
|
|
"""
|
|
|
|
Editable installations should not change branch
|
|
|
|
related to issue #32 and #161
|
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
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,
|
|
|
|
)
|
2014-02-24 22:52:23 +01:00
|
|
|
source_dir = script.venv_path / 'src' / 'pip-test-package'
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.run('git', 'branch', cwd=source_dir)
|
2011-10-23 08:28:25 +02:00
|
|
|
assert '* master' in result.stdout, result.stdout
|
2010-11-22 20:34:31 +01:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_git_with_non_editable_unpacking(script, tmpdir):
|
2010-11-22 20:34:31 +01:00
|
|
|
"""
|
|
|
|
Test cloning a git repository from a non-editable URL with a given tag.
|
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '--global-option=--version',
|
|
|
|
local_checkout(
|
|
|
|
'git+http://github.com/pypa/pip-test-package.git@0.1.2'
|
|
|
|
'#egg=pip-test-package',
|
|
|
|
tmpdir.join("cache")
|
|
|
|
),
|
|
|
|
expect_error=True,
|
|
|
|
)
|
2012-06-03 00:30:45 +02:00
|
|
|
assert '0.1.2' in result.stdout
|
2010-12-09 03:34:14 +01:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_git_with_editable_where_egg_contains_dev_string(script, tmpdir):
|
2010-12-09 03:34:14 +01:00
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
Test cloning a git repository from an editable url which contains "dev"
|
|
|
|
string
|
2010-12-09 03:34:14 +01:00
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '-e',
|
|
|
|
'%s#egg=django-devserver' %
|
|
|
|
local_checkout(
|
|
|
|
'git+git://github.com/dcramer/django-devserver.git',
|
2014-02-24 22:52:23 +01:00
|
|
|
tmpdir.join("cache")
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2014-02-24 22:52:23 +01:00
|
|
|
)
|
2010-12-09 03:34:14 +01:00
|
|
|
result.assert_installed('django-devserver', with_files=['.git'])
|
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_git_with_non_editable_where_egg_contains_dev_string(script, tmpdir):
|
2010-12-09 03:34:14 +01:00
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
Test cloning a git repository from a non-editable url which contains "dev"
|
|
|
|
string
|
2010-12-09 03:34:14 +01:00
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install',
|
|
|
|
'%s#egg=django-devserver' %
|
|
|
|
local_checkout(
|
|
|
|
'git+git://github.com/dcramer/django-devserver.git',
|
2014-02-24 22:52:23 +01:00
|
|
|
tmpdir.join("cache")
|
|
|
|
),
|
|
|
|
)
|
|
|
|
devserver_folder = script.site_packages / 'devserver'
|
2010-12-09 03:34:14 +01:00
|
|
|
assert devserver_folder in result.files_created, str(result)
|
2011-05-15 17:47:06 +02:00
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_git_with_ambiguous_revs(script):
|
2011-05-15 17:47:06 +02:00
|
|
|
"""
|
|
|
|
Test git with two "names" (tag/branch) pointing to the same commit
|
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
version_pkg_path = _create_test_package(script)
|
2014-01-28 15:17:51 +01:00
|
|
|
package_url = (
|
|
|
|
'git+file://%s@0.1#egg=version_pkg' %
|
|
|
|
(version_pkg_path.abspath.replace('\\', '/'))
|
|
|
|
)
|
2013-08-21 11:16:07 +02:00
|
|
|
script.run('git', 'tag', '0.1', cwd=version_pkg_path)
|
|
|
|
result = script.pip('install', '-e', package_url)
|
2011-05-15 17:47:06 +02:00
|
|
|
assert 'Could not find a tag or branch' not in result.stdout
|
|
|
|
# it is 'version-pkg' instead of 'version_pkg' because
|
|
|
|
# egg-link name is version-pkg.egg-link because it is a single .py module
|
|
|
|
result.assert_installed('version-pkg', with_files=['.git'])
|
2012-03-24 19:26:34 +01:00
|
|
|
|
2012-04-14 05:41:33 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_git_works_with_editable_non_origin_repo(script):
|
2014-01-28 15:17:51 +01:00
|
|
|
# set up, create a git repo and install it as editable from a local
|
|
|
|
# directory path
|
2013-08-21 11:16:07 +02:00
|
|
|
version_pkg_path = _create_test_package(script)
|
|
|
|
script.pip('install', '-e', version_pkg_path.abspath)
|
2012-03-24 19:26:34 +01:00
|
|
|
|
2014-01-28 15:17:51 +01:00
|
|
|
# 'freeze'ing this should not fall over, but should result in stderr output
|
|
|
|
# warning
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip('freeze', expect_stderr=True)
|
2012-04-14 05:41:33 +02:00
|
|
|
assert "Error when trying to get requirement" in result.stderr
|
|
|
|
assert "Could not determine repository location" in result.stdout
|
|
|
|
assert "version-pkg==0.1" in result.stdout
|