diff --git a/pipenv/project.py b/pipenv/project.py index effaa17e..70e05006 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -615,8 +615,12 @@ class Project(object): def pipfile_sources(self): if 'source' in self.parsed_pipfile: sources = [] - for s in self.parsed_pipfile['source']: - s['url'] = os.path.expandvars(s['url']) + for i, s in enumerate(self.parsed_pipfile['source']): + for k in s.keys(): + if k == 'verify_ssl': + continue + val = os.path.expandvars(self.parsed_pipfile['source'][i][k]) + s[k] = val sources.append(s) return sources return [DEFAULT_SOURCE] @@ -629,10 +633,8 @@ class Project(object): if sources_: return sources_ - if 'source' in self.parsed_pipfile: - return self.parsed_pipfile['source'] else: - return [DEFAULT_SOURCE] + return self.pipfile_sources def find_source(self, source): """given a source, find it. diff --git a/tests/integration/test_project.py b/tests/integration/test_project.py index 4e8fe44a..62781c11 100644 --- a/tests/integration/test_project.py +++ b/tests/integration/test_project.py @@ -2,6 +2,30 @@ import pytest import os from pipenv.project import Project +from pipenv.utils import temp_environ +from pipenv.patched import pipfile + + +@pytest.mark.project +@pytest.mark.sources +@pytest.mark.environ +def test_pipfile_envvar_expansion(PipenvInstance): + with PipenvInstance(chdir=True) as p: + with temp_environ(): + with open(p.pipfile_path, 'w') as f: + f.write(""" +[[source]] +url = 'https://${TEST_HOST}/simple' +verify_ssl = false +name = "pypi" + +[packages] +pytz = "*" + """.strip()) + os.environ['TEST_HOST'] = 'localhost:5000' + project = Project() + assert project.sources[0]['url'] == 'https://localhost:5000/simple' + assert 'localhost:5000' not in str(pipfile.load(p.pipfile_path)) @pytest.mark.project