From 70a69fe38032a44b86d1dde019edfb1374f8066e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ba=C5=A1ti?= Date: Tue, 22 Dec 2020 12:28:30 +0100 Subject: [PATCH] Sort CLI output alphabetically MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide consistent output that is not dependent on py dict implemetation Signed-off-by: Martin Bašti --- koji_containerbuild/plugins/cli_containerbuild.py | 4 ++-- tests/test_cli_containerbuild.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/koji_containerbuild/plugins/cli_containerbuild.py b/koji_containerbuild/plugins/cli_containerbuild.py index ec2cb87c..a4ed17f6 100644 --- a/koji_containerbuild/plugins/cli_containerbuild.py +++ b/koji_containerbuild/plugins/cli_containerbuild.py @@ -42,9 +42,9 @@ def print_result(result, level=0, indent=2): for item in result: print_result(item, level+1) elif isinstance(result, dict): - for key, value in result.items(): + for key in sorted(result): print_value(key, level, indent, ':') - print_result(value, level+1) + print_result(result[key], level+1) else: print_value(result, level, indent) diff --git a/tests/test_cli_containerbuild.py b/tests/test_cli_containerbuild.py index e7d4520c..10f4c8e8 100644 --- a/tests/test_cli_containerbuild.py +++ b/tests/test_cli_containerbuild.py @@ -125,9 +125,9 @@ def _expected_output(result, offset, indent): for line in _expected_output(item, offset+indent, indent): yield line elif isinstance(result, dict): - for key, value in result.items(): + for key in sorted(result): yield '{}{}:\n'.format(offset, key) - for line in _expected_output(value, offset+indent, indent): + for line in _expected_output(result[key], offset+indent, indent): yield line else: yield '{}{}\n'.format(offset, result)