From 8c0936faf6766aa1fbc477af8d57969e2584f828 Mon Sep 17 00:00:00 2001 From: Grey Baker Date: Tue, 1 May 2018 13:30:56 +0100 Subject: [PATCH 1/2] Always use sources from Pipfile when doing resolution --- pipenv/resolver.py | 2 +- tests/integration/test_lock.py | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/pipenv/resolver.py b/pipenv/resolver.py index c04a6b3c..7e4b95d3 100644 --- a/pipenv/resolver.py +++ b/pipenv/resolver.py @@ -68,7 +68,7 @@ def main(): results = resolve( packages, pre=do_pre, - sources=project.sources, + sources=project.pipfile_sources, verbose=is_verbose, clear=do_clear, system=system, diff --git a/tests/integration/test_lock.py b/tests/integration/test_lock.py index 29d472e5..e21c7dab 100644 --- a/tests/integration/test_lock.py +++ b/tests/integration/test_lock.py @@ -1,4 +1,5 @@ import pytest +import os from flaky import flaky @@ -210,3 +211,41 @@ requests = "*" assert c.return_code == 0 assert '-i https://pypi.python.org/simple' in c.out.strip() assert '--extra-index-url https://test.pypi.org/simple' in c.out.strip() + + +@pytest.mark.install +@pytest.mark.index +def test_lock_updated_source(PipenvInstance, pypi): + + with PipenvInstance(pypi=pypi) as p: + with open(p.pipfile_path, 'w') as f: + contents = """ +[[source]] +url = "https://pypi.python.org/${MY_ENV_VAR}" + +[packages] +requests = "==2.14.0" + """.strip() + f.write(contents) + + os.environ['MY_ENV_VAR'] = 'simple' + c = p.pipenv('lock') + assert c.return_code == 0 + assert 'requests' in p.lockfile['default'] + + del os.environ['MY_ENV_VAR'] + + with open(p.pipfile_path, 'w') as f: + contents = """ +[[source]] +url = "https://pypi.python.org/simple" + +[packages] +requests = "==2.14.0" + """.strip() + f.write(contents) + + c = p.pipenv('lock') + assert c.return_code == 0 + assert 'requests' in p.lockfile['default'] + From 2dc999292e22cc8c9243868bf5917f8468aa16b5 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Wed, 2 May 2018 17:07:49 +0800 Subject: [PATCH 2/2] Use the mock PyPI --- tests/integration/test_lock.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/test_lock.py b/tests/integration/test_lock.py index 7aa9bc42..a14b8b10 100644 --- a/tests/integration/test_lock.py +++ b/tests/integration/test_lock.py @@ -258,11 +258,11 @@ def test_lock_updated_source(PipenvInstance, pypi): with open(p.pipfile_path, 'w') as f: contents = """ [[source]] -url = "https://pypi.python.org/${MY_ENV_VAR}" +url = "{url}/${{MY_ENV_VAR}}" [packages] requests = "==2.14.0" - """.strip() + """.strip().format(url=pypi.url) f.write(contents) os.environ['MY_ENV_VAR'] = 'simple' @@ -275,11 +275,11 @@ requests = "==2.14.0" with open(p.pipfile_path, 'w') as f: contents = """ [[source]] -url = "https://pypi.python.org/simple" +url = "{url}/simple" [packages] requests = "==2.14.0" - """.strip() + """.strip().format(url=pypi.url) f.write(contents) c = p.pipenv('lock')