Skip to content

Commit 76466f2

Browse files
authored
Merge branch 'master' into early-python-executable-check
2 parents 6927770 + 573db7b commit 76466f2

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

pipenv/project.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,12 @@ def write_toml(self, data, path=None):
615615
def pipfile_sources(self):
616616
if 'source' in self.parsed_pipfile:
617617
sources = []
618-
for s in self.parsed_pipfile['source']:
619-
s['url'] = os.path.expandvars(s['url'])
618+
for i, s in enumerate(self.parsed_pipfile['source']):
619+
for k in s.keys():
620+
if k == 'verify_ssl':
621+
continue
622+
val = os.path.expandvars(self.parsed_pipfile['source'][i][k])
623+
s[k] = val
620624
sources.append(s)
621625
return sources
622626
return [DEFAULT_SOURCE]
@@ -629,10 +633,8 @@ def sources(self):
629633
if sources_:
630634
return sources_
631635

632-
if 'source' in self.parsed_pipfile:
633-
return self.parsed_pipfile['source']
634636
else:
635-
return [DEFAULT_SOURCE]
637+
return self.pipfile_sources
636638

637639
def find_source(self, source):
638640
"""given a source, find it.

tests/integration/test_project.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22
import pytest
33
import os
44
from pipenv.project import Project
5+
from pipenv.utils import temp_environ
6+
from pipenv.patched import pipfile
7+
8+
9+
@pytest.mark.project
10+
@pytest.mark.sources
11+
@pytest.mark.environ
12+
def test_pipfile_envvar_expansion(PipenvInstance):
13+
with PipenvInstance(chdir=True) as p:
14+
with temp_environ():
15+
with open(p.pipfile_path, 'w') as f:
16+
f.write("""
17+
[[source]]
18+
url = 'https://${TEST_HOST}/simple'
19+
verify_ssl = false
20+
name = "pypi"
21+
22+
[packages]
23+
pytz = "*"
24+
""".strip())
25+
os.environ['TEST_HOST'] = 'localhost:5000'
26+
project = Project()
27+
assert project.sources[0]['url'] == 'https://localhost:5000/simple'
28+
assert 'localhost:5000' not in str(pipfile.load(p.pipfile_path))
529

630

731
@pytest.mark.project

0 commit comments

Comments
 (0)