fix(pip/req/req_set): If double requirements exist which have the same specs, dont raise a double requirement given error

This commit is contained in:
kaustav haldar 2016-01-18 15:30:26 -08:00
parent 3ae13b2e35
commit fbfa7fbcfe
2 changed files with 21 additions and 1 deletions

View File

@ -242,7 +242,8 @@ class RequirementSet(object):
existing_req = None
if (parent_req_name is None and existing_req and not
existing_req.constraint and
existing_req.extras == install_req.extras):
existing_req.extras == install_req.extras and not
existing_req.req.specs == install_req.req.specs):
raise InstallationError(
'Double requirement given: %s (already in %s, name=%r)'
% (install_req, existing_req, name))

View File

@ -932,3 +932,22 @@ def test_install_tar_lzma(script, data):
pytest.skip("No lzma support")
res = script.pip('install', data.packages / 'singlemodule-0.0.1.tar.lzma')
assert "Successfully installed singlemodule-0.0.1" in res.stdout, res
def test_double_install(script, data):
"""
Test double install passing with two same version requirements
"""
result = script.pip('install', 'pip', 'pip', expect_error=False)
msg = "Double requirement given: pip (already in pip, name='pip')"
assert msg not in result.stderr
def test_double_install_fail(script, data):
"""
Test double install failing with two different version requirements
"""
result = script.pip('install', 'pip==*', 'pip==7.1.2', expect_error=True)
msg = ("Double requirement given: pip==7.1.2 (already in pip==*, "
"name='pip')")
assert msg in result.stderr