From 5d76b404f4e53d35ce342907b43a0c658a0c5b4f Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sat, 23 Jun 2018 03:01:20 -0400 Subject: [PATCH] Add some tests - the rest of the to-do items are at https://github.com/pypa/pipenv/projects/2 - We just need to review the items in the 'needs tests' column to ensure that they either have tests, or don't need to have tests - If they need tests, and they don't yet have tests, we need to write them and make sure they pass - Then we can release. No more features/bugfixes, this is now how it's going out. Signed-off-by: Dan Ryan --- tests/integration/test_install_twists.py | 42 +++++++++++++++--------- tests/integration/test_lock.py | 29 ++++++++++++---- tests/unit/test_utils.py | 7 ++++ 3 files changed, 56 insertions(+), 22 deletions(-) diff --git a/tests/integration/test_install_twists.py b/tests/integration/test_install_twists.py index 91cdf329..dfa265a2 100644 --- a/tests/integration/test_install_twists.py +++ b/tests/integration/test_install_twists.py @@ -1,6 +1,6 @@ import os import shutil - +from pipenv.project import Project try: import pathlib except ImportError: @@ -16,36 +16,46 @@ from flaky import flaky @pytest.mark.extras @pytest.mark.install @pytest.mark.local -@pytest.mark.skip(reason="I'm not mocking this.") -def test_local_extras_install(PipenvInstance, pypi): - with PipenvInstance(pypi=pypi) as p: +@pytest.mark.parametrize('line, pipfile', [ + ['-e .[dev]', {'testpipenv': {'path': '.', 'editable': True, 'extras': ['dev']}}] +]) +def test_local_extras_install(PipenvInstance, pypi, line, pipfile): + """Test -e .[extras] installs... note that the extras themselves + are currently not landing in the lockfile for reasons that are unclear. + """ + with PipenvInstance(pypi=pypi, chdir=True) as p: + project = Project() setup_py = os.path.join(p.path, 'setup.py') with open(setup_py, 'w') as fh: contents = """ from setuptools import setup, find_packages - setup( -name='test_pipenv', +name='testpipenv', version='0.1', description='Pipenv Test Package', author='Pipenv Test', author_email='test@pipenv.package', -license='PIPENV', +license='MIT', packages=find_packages(), -install_requires=['tablib'], -extras_require={'dev': ['flake8', 'pylint']}, +install_requires=[], +extras_require={'dev': ['six']}, zip_safe=False ) """.strip() fh.write(contents) - c = p.pipenv('install .[dev]') + project.write_toml({'packages': pipfile, 'dev-packages': {}}) + c = p.pipenv('install') assert c.return_code == 0 - key = [k for k in p.pipfile['packages'].keys()][0] - dep = p.pipfile['packages'][key] - assert dep['path'] == '.' - assert dep['extras'] == ['dev'] - assert key in p.lockfile['default'] - assert 'dev' in p.lockfile['default'][key]['extras'] + assert 'testpipenv' in p.lockfile['default'] + assert p.lockfile['default']['testpipenv']['extras'] == ['dev'] + c = p.pipenv('--rm') + assert c.return_code == 0 + project.write_toml({'packages': {}, 'dev-packages': {}}) + c = p.pipenv('install {0}'.format(line)) + assert c.return_code == 0 + assert 'testpipenv' in p.pipfile['packages'] + assert p.pipfile['packages']['testpipenv']['path'] in ['.', './.'] + assert p.pipfile['packages']['testpipenv']['extras'] == ['dev'] @pytest.mark.e diff --git a/tests/integration/test_lock.py b/tests/integration/test_lock.py index ce57e544..0dfd22bb 100644 --- a/tests/integration/test_lock.py +++ b/tests/integration/test_lock.py @@ -307,12 +307,11 @@ requests = "==2.14.0" """.strip().format(url=pypi.url) 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 temp_environ(): + os.environ['MY_ENV_VAR'] = 'simple' + c = p.pipenv('lock') + assert c.return_code == 0 + assert 'requests' in p.lockfile['default'] with open(p.pipfile_path, 'w') as f: contents = """ @@ -328,3 +327,21 @@ requests = "==2.14.0" assert c.return_code == 0 assert 'requests' in p.lockfile['default'] + +@pytest.mark.lock +@pytest.mark.vcs +@pytest.mark.needs_internet +def 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(""" +[packages] +requests = {git = "https://github.com/requests/requests.git", ref = "master", editable = true} + """.strip()) + c = p.pipenv('lock') + assert c.return_code == 0 + assert 'requests' in p.lockfile['default'] + assert 'idna' in p.lockfile['default'] + assert 'chardet' in p.lockfile['default'] + c = p.pipenv('install') + assert c.return_code == 0 diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 7847551a..361108dd 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -60,6 +60,13 @@ DEP_PIP_PAIRS = [ }}, 'git+https://github.com/requests/requests.git@master#egg=requests[security]', ), + ( + {'local_path': { + 'path': '.', + 'extras': ['dev'] + }}, + '.[dev]' + ) ]