diff --git a/pipenv/utils.py b/pipenv/utils.py index 8aab88df..7e8ab4fd 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -646,11 +646,12 @@ class Resolver: req.requirement.marker and not req.requirement.marker.evaluate() ): pypi = resolver.finder if resolver else None - name, specifier = req.ireq.name, req.ireq.specifier - best_match = pypi.find_best_candidate(name, specifier).best_candidate if pypi else None + ireq = req.ireq + best_match = pypi.find_best_candidate(ireq.name, ireq.specifier).best_candidate if pypi else None if best_match: - hashes = resolver.collect_hashes(best_match) if resolver else [] - new_req = Requirement.from_ireq(best_match) + ireq.req.specifier = ireq.specifier.__class__(f"=={best_match.version}") + hashes = resolver.collect_hashes(ireq) if resolver else [] + new_req = Requirement.from_ireq(ireq) new_req = new_req.add_hashes(hashes) name, entry = new_req.pipfile_entry locked_deps[pep423_name(name)] = translate_markers(entry) @@ -980,7 +981,7 @@ class Resolver: if link.hash and link.hash_name == shims.FAVORITE_HASH: return f"{link.hash_name}:{link.hash}" - return self.hash_cache.get(link) + return self.hash_cache.get_hash(link) def _clean_skipped_result(self, req, value): ref = None diff --git a/tests/integration/test_install_markers.py b/tests/integration/test_install_markers.py index 96afc37b..1bb28eb1 100644 --- a/tests/integration/test_install_markers.py +++ b/tests/integration/test_install_markers.py @@ -127,8 +127,6 @@ funcsigs = "*" @flaky @pytest.mark.markers @pytest.mark.complex -@pytest.mark.py3_only -@pytest.mark.skip("test is flaky on CI") def test_resolver_unique_markers(PipenvInstance): """vcrpy has a dependency on `yarl` which comes with a marker of 'python version in "3.4, 3.5, 3.6" - this marker duplicates itself: @@ -140,8 +138,6 @@ def test_resolver_unique_markers(PipenvInstance): with PipenvInstance(chdir=True) as p: c = p.pipenv('install vcrpy==2.0.1') assert c.returncode == 0 - c = p.pipenv('lock') - assert c.returncode == 0 assert 'yarl' in p.lockfile['default'] yarl = p.lockfile['default']['yarl'] assert 'markers' in yarl diff --git a/tests/unit/test_patched.py b/tests/unit/test_patched.py deleted file mode 100644 index 7137ea2f..00000000 --- a/tests/unit/test_patched.py +++ /dev/null @@ -1,131 +0,0 @@ -import pytest - -from notpip._internal.index.package_finder import PackageFinder - - -get_extras_links_scenarios = { - 'windows and not windows': ( - [ - 'chardet', - '[:platform_system != "windows"]', - 'twisted', - '[:platform_system == "windows"]', - 'twisted[windows_platform]', - ], - { - ':platform_system != "windows"': [ - 'twisted', - ], - ':platform_system == "windows"': [ - 'twisted[windows_platform]', - ], - }, - ), - 'requests': ( - [ - 'chardet<3.1.0,>=3.0.2', - 'idna<2.7,>=2.5', - 'urllib3<1.23,>=1.21.1', - 'certifi>=2017.4.17', - '[security]', - 'pyOpenSSL>=0.14', - 'cryptography>=1.3.4', - 'idna>=2.0.0', - '[socks]', - 'PySocks!=1.5.7,>=1.5.6', - ( - '[socks:sys_platform == "win32"' - ' and (python_version == "2.7" or python_version == "2.6")]' - ), - 'win_inet_pton', - ], - { - 'security': [ - 'pyOpenSSL>=0.14', - 'cryptography>=1.3.4', - 'idna>=2.0.0', - ], - 'socks': [ - 'PySocks!=1.5.7,>=1.5.6', - ], - 'socks:sys_platform == "win32" ' - 'and (python_version == "2.7" or python_version == "2.6")': [ - 'win_inet_pton', - ], - } - ), - 'attrs': ( - [ - '[dev]', - 'coverage', - 'hypothesis', - 'pympler', - 'pytest', - 'six', - 'zope.interface', - 'sphinx', - 'zope.interface', - '[docs]', - 'sphinx', - 'zope.interface', - '[tests]', - 'coverage', - 'hypothesis', - 'pympler', - 'pytest', - 'six', - 'zope.interface', - ], - { - 'dev': [ - 'coverage', - 'hypothesis', - 'pympler', - 'pytest', - 'six', - 'zope.interface', - 'sphinx', - 'zope.interface', - ], - 'docs': [ - 'sphinx', - 'zope.interface', - ], - 'tests': [ - 'coverage', - 'hypothesis', - 'pympler', - 'pytest', - 'six', - 'zope.interface', - ], - }, - ), - 'misc': ( - [ - 'chardet', - '[:platform_system != "windows"]', - 'attrs', - '[:platform_system == "windows"]', - 'pytz', - ], - { - ':platform_system != "windows"': [ - 'attrs', - ], - ':platform_system == "windows"': [ - 'pytz', - ], - }, - ), -} - - -@pytest.mark.patched -@pytest.mark.parametrize( - 'scenarios,expected', - list(get_extras_links_scenarios.values()), - ids=list(get_extras_links_scenarios.keys()), -) -def test_get_extras_links(scenarios, expected): - assert PackageFinder.get_extras_links(scenarios) == expected