-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #5624: installing a Git ref for installs other than the first #5623
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Allow a Git ref to be installed over an existing installation. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,23 +180,52 @@ def test_git_with_tag_name_as_revision(script): | |
assert '0.1' in version.stdout | ||
|
||
|
||
@pytest.mark.network | ||
def test_git_with_ref_as_revision(script): | ||
def _add_ref(script, path, ref): | ||
""" | ||
Git backend should be able to install from a ref | ||
Add a new ref to a repository at the given path. | ||
""" | ||
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 | ||
) | ||
script.run('git', 'update-ref', ref, 'HEAD', expect_stderr=True, cwd=path) | ||
|
||
|
||
def make_version_pkg_url(path, revision=None): | ||
path = path.abspath.replace('\\', '/') | ||
url_rev = '' if revision is None else '@' + revision | ||
url = 'git+file://{}{}#egg=version_pkg'.format(path, url_rev) | ||
|
||
return url | ||
|
||
|
||
def test_git_install_ref(script): | ||
""" | ||
The Git backend should be able to install a ref with the first install. | ||
""" | ||
package_path = _create_test_package(script) | ||
_add_ref(script, package_path, 'refs/foo/bar') | ||
_change_test_package_version(script, package_path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it necessary to run this here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think so because otherwise |
||
|
||
package_url = make_version_pkg_url(package_path, revision='refs/foo/bar') | ||
script.pip('install', '-e', package_url, expect_stderr=True) | ||
version = script.run('version_pkg') | ||
assert '0.1' in version.stdout | ||
|
||
|
||
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. | ||
""" | ||
package_path = _create_test_package(script) | ||
_add_ref(script, package_path, 'refs/foo/bar') | ||
_change_test_package_version(script, package_path) | ||
|
||
package_url = make_version_pkg_url(package_path) | ||
script.pip('install', '-e', package_url, expect_stderr=True) | ||
version = script.run('version_pkg') | ||
assert 'some different version' in version.stdout | ||
|
||
# Now install the ref. | ||
package_url = make_version_pkg_url(package_path, revision='refs/foo/bar') | ||
script.pip('install', '-e', package_url, expect_stderr=True) | ||
version = script.run('version_pkg') | ||
assert '0.1' in version.stdout | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like these tests lost the
@pytest.mark.network
decorator. I'm not 100% sure what the mark means in the context of this test suite, but all the other tests in this file have it, perhaps these two should as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The decorator is essentially for marking all tests that reach out to the network.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I removed it because
_create_test_package()
creates the source package on the file system, and the package is installed with the'git+file://
scheme (seemake_version_pkg_url()
a few lines above).I thought the
network
decorator was only meant for cases where the test was reaching out to an external network, liketest_install_noneditable_git
, which installs from GitHub (with urlgit+https://github.com/pypa/pip-test-package.git
). It looked to me like some other tests in the file might also have the decorator unnecessarily.Technically, I guess the Git docs do say that
file://
"fires up the processes that it normally uses to transfer data over a network, which is generally much less efficient," but it seems like there is a big difference between using the same "processes" for network activity and actually reaching out to an external network location like, say, GitHub. What do you both think? I'm guessing the decorator is used to help partition tests for CI purposes (e.g. which tests are slower or depend on external networks, etc).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The partitioning is so that you can run tests while not connected to the internet.
If this test runs with no internet connectivity, then it doesn't need this decorator and vice versa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll leave the decorator off then because as near as I can tell it doesn't require internet connectivity.