From 2b1ea9ee8a0449586cc677374d6070365a67b0fa Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Fri, 23 Nov 2018 18:06:12 -0500 Subject: [PATCH] Add test Signed-off-by: Dan Ryan --- tests/integration/test_lock.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/integration/test_lock.py b/tests/integration/test_lock.py index 831b1644..8ab56081 100644 --- a/tests/integration/test_lock.py +++ b/tests/integration/test_lock.py @@ -1,5 +1,6 @@ import pytest import os +import sys from pipenv.utils import temp_environ @@ -517,3 +518,25 @@ def test_lock_no_warnings(PipenvInstance, pypi): assert "Warning" in c.err assert "Warning" not in c.out assert "hello" in c.out + + +@pytest.mark.lock +@pytest.mark.install +@pytest.mark.skipif(sys.version_info >= (3, 5), reason="scandir doesn't get installed on python 3.5+") +def test_lock_missing_cache_entries_gets_all_hashes(monkeypatch, PipenvInstance, pypi, tmpdir): + """ + Test locking pathlib2 on python2.7 which needs `scandir`, but fails to resolve when + using a fresh dependency cache. + """ + + with monkeypatch.context() as m: + monkeypatch.setattr("pipenv.patched.piptools.locations.CACHE_DIR", tmpdir.strpath) + with PipenvInstance(pypi=pypi, chdir=True) as p: + p._pipfile.add("pathlib2", "*") + assert "pathlib2" in p.pipfile["packages"] + c = p.pipenv("install") + assert c.return_code == 0, c.err + assert "pathlib2" in p.lockfile["default"] + assert "scandir" in p.lockfile["default"] + assert isinstance(p.lockfile["default"]["scandir"]["hashes"], list) + assert len(p.lockfile["default"]["scandir"]["hashes"]) > 1