InstallRequirement.url should preserve the initial value for from_line requirements

This commit is contained in:
Marcus Smith 2014-08-03 21:01:12 -07:00
parent fcdde73e9f
commit 4eb9e3297f
2 changed files with 14 additions and 2 deletions

View File

@ -132,7 +132,7 @@ class InstallRequirement(object):
# it's a local file, dir, or url
if link:
url = link.url_without_fragment
url = link.url
# Handle relative file URLs
if link.scheme == 'file' and re.search(r'\.\./', url):
url = path_to_url(os.path.normpath(os.path.abspath(link.path)))

View File

@ -79,7 +79,7 @@ class TestInstallRequirement(object):
url = 'http://foo.com/?p=bar.git;a=snapshot;h=v0.1;sf=tgz'
fragment = '#egg=bar'
req = InstallRequirement.from_line(url + fragment)
assert req.url == url, req.url
assert req.url == url + fragment, req.url
def test_unsupported_wheel_requirement_raises(self):
with pytest.raises(UnsupportedWheel):
@ -95,6 +95,18 @@ class TestInstallRequirement(object):
req = InstallRequirement.from_line('simple-0.1-py2.py3-none-any.whl')
assert req.req == pkg_resources.Requirement.parse('simple==0.1')
def test_url_preserved_line_req(self):
"""Confirm the url is preserved in a non-editable requirement"""
url = 'http://foo.com@ref#egg=foo'
req = InstallRequirement.from_line(url)
assert req.url == url
def test_url_preserved_editable_req(self):
"""Confirm the url is preserved in a editable requirement"""
url = 'http://foo.com@ref#egg=foo'
req = InstallRequirement.from_editable(url)
assert req.url == url
def test_requirements_data_structure_keeps_order():
requirements = Requirements()