Merge pull request #2437 from frostming/bugfix/1901-tests

Add test case for #1901
This commit is contained in:
Dan Ryan
2018-06-27 01:20:04 -04:00
committed by GitHub
3 changed files with 25 additions and 4 deletions
+9 -3
View File
@@ -180,12 +180,18 @@ class HackedPythonVersion(object):
self.python_path = python_path
def __enter__(self):
os.environ['PIP_PYTHON_VERSION'] = str(self.python_version)
os.environ['PIP_PYTHON_PATH'] = str(self.python_path)
# Only inject when the value is valid
if self.python_version:
os.environ['PIP_PYTHON_VERSION'] = str(self.python_version)
if self.python_path:
os.environ['PIP_PYTHON_PATH'] = str(self.python_path)
def __exit__(self, *args):
# Restore original Python version information.
del os.environ['PIP_PYTHON_VERSION']
try:
del os.environ['PIP_PYTHON_VERSION']
except KeyError:
pass
def prepare_pip_source_args(sources, pip_args=None):
+16 -1
View File
@@ -1,5 +1,6 @@
import pytest
import os
import six
from pipenv.utils import temp_environ
@@ -331,7 +332,7 @@ requests = "==2.14.0"
@pytest.mark.lock
@pytest.mark.vcs
@pytest.mark.needs_internet
def lock_editable_vcs_without_install(PipenvInstance, pypi):
def test_lock_editable_vcs_without_install(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi, chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
f.write("""
@@ -345,3 +346,17 @@ requests = {git = "https://github.com/requests/requests.git", ref = "master", ed
assert 'chardet' in p.lockfile['default']
c = p.pipenv('install')
assert c.return_code == 0
@pytest.mark.lock
def test_lock_respecting_python_version(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
with open(p.pipfile_path, 'w') as f:
f.write("""
[packages]
django = "*"
""".strip())
django_version = '==2.0.6' if six.PY3 else '==1.11.10'
c = p.pipenv('lock')
assert c.return_code == 0
assert p.lockfile['default']['django']['version'] == django_version
Binary file not shown.