From d124e382a1b7fd2de6046baacbf3c86cb70880cb Mon Sep 17 00:00:00 2001 From: Nate Prewitt Date: Thu, 1 Jun 2017 10:10:58 -0600 Subject: [PATCH] fix requirements output and add test --- pipenv/cli.py | 2 +- tests/test_pipenv.py | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 7d369ce4..f5138670 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -255,7 +255,7 @@ def do_install_dependencies(dev=False, only=False, bare=False, requirements=Fals # --requirements was passed. if requirements: - click.echo('\n'.join(deps_list)) + click.echo('\n'.join(d[0] for d in deps_list)) sys.exit(0) # pip install: diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 237b3e29..9e4135f6 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -298,3 +298,29 @@ class TestPipenv(): c = pip_download('package') assert c.return_code == 0 assert c == first_cmd_return + + def test_lock_requirements_file(self): + delegator.run('mkdir test_pipenv_requirements') + os.chdir('test_pipenv_requirements') + + pip_str = ("[packages]\n" + "requests = \"==2.14.0\"\n" + "flask = \"==0.12.2\"\n\n" + "[dev-packages]\n" + "pytest = \"==3.1.1\"\n") + + req_list = ("requests==2.14.0", "flask==0.12.2", "pytest==3.1.1") + + # Build the environment. + os.environ['PIPENV_VENV_IN_PROJECT'] = '1' + assert delegator.run('echo \'{0}\' > Pipfile'.format(pip_str)).return_code == 0 + + # Validate requirements.txt. + c = delegator.run('pipenv lock -r') + assert c.return_code == 0 + for req in req_list: + assert req in c.out + + # Cleanup. + os.chdir('..') + delegator.run('rm -fr test_pipenv_requirements')