From 622d119ea658b66baeaf5d64ba9205f34199d6d9 Mon Sep 17 00:00:00 2001 From: Glen Smith Date: Fri, 28 Aug 2020 15:14:35 -0600 Subject: [PATCH] Fix `script` command and testing: - Use string format compatible with python 2.7 - Use `click.echo`, not `print` - The command is `pipenv script` not `pipenv scripts` - The stanza label in Pipfile is `[scripts]`, not `[script]` - The default when getting from the pipfile should be dict, not a list --- pipenv/cli/command.py | 9 +++++---- tests/integration/test_cli.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pipenv/cli/command.py b/pipenv/cli/command.py index 86e31454..340e95b3 100644 --- a/pipenv/cli/command.py +++ b/pipenv/cli/command.py @@ -727,12 +727,13 @@ def script(state, args): """Lists scripts in current environment config.""" from ..core import project if not project: - print("project not found") + echo(u"project not found", err=True) exit(1) - scripts = project.parsed_pipfile.get('scripts', []) - print("command\tscript") + scripts = project.parsed_pipfile.get('scripts', {}) + rpt = u"command\tscript\n" for k, v in scripts.items(): - print(f"{k}\t{v}") + rpt += u"{0}\t{1}".format(k, v) + echo(rpt) return diff --git a/tests/integration/test_cli.py b/tests/integration/test_cli.py index e48c15de..d37b4bf1 100644 --- a/tests/integration/test_cli.py +++ b/tests/integration/test_cli.py @@ -202,7 +202,7 @@ def test_scripts(PipenvInstance): with PipenvInstance() as p: with open(p.pipfile_path, "w") as f: contents = """ -[script] +[scripts] pyver = "which python" """.strip() f.write(contents)