Mercurial > piecrust2
changeset 567:a65f04ddbea2
showconfig: Don't crash when the whole config should be shown.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 13 Oct 2015 22:46:05 -0700 |
parents | 8073ae8cb164 |
children | 6b6c5442c790 |
files | piecrust/commands/builtin/info.py tests/cli/test_showconfig.yaml tests/conftest.py |
diffstat | 3 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/commands/builtin/info.py Sat Oct 10 23:02:40 2015 -0700 +++ b/piecrust/commands/builtin/info.py Tue Oct 13 22:46:05 2015 -0700 @@ -35,7 +35,11 @@ nargs='?') def run(self, ctx): - show = ctx.app.config.get(ctx.args.path) + if ctx.args.path: + show = ctx.app.config.get(ctx.args.path) + else: + show = ctx.app.config.getAll() + if show is not None: if isinstance(show, (dict, list)): import yaml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/cli/test_showconfig.yaml Tue Oct 13 22:46:05 2015 -0700 @@ -0,0 +1,3 @@ +--- +args: showconfig +
--- a/tests/conftest.py Sat Oct 10 23:02:40 2015 -0700 +++ b/tests/conftest.py Tue Oct 13 22:46:05 2015 -0700 @@ -149,7 +149,7 @@ argv = argv.split(' ') expected_code = self.spec.get('code', 0) - expected_out = self.spec.get('out', '') + expected_out = self.spec.get('out', None) with mock_fs_scope(fs): memstream = io.StringIO() @@ -165,10 +165,11 @@ assert expected_code == exit_code - actual_out = memstream.getvalue() - if self.spec.get('replace_out_path_sep'): - expected_out = expected_out.replace('/', os.sep) - assert expected_out == actual_out + if expected_out is not None: + actual_out = memstream.getvalue() + if self.spec.get('replace_out_path_sep'): + expected_out = expected_out.replace('/', os.sep) + assert expected_out == actual_out def reportinfo(self): return self.fspath, 0, "bake: %s" % self.name