From 53970d52fcf64fefb446b8774f958c28a045c112 Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org> Date: Wed, 26 Jul 2023 10:49:19 +0200 Subject: [PATCH] test: Fix test for older click version With older click version (e.g. 7.0-1), the text wrapping can be different, resulting in some docstring text included in this command list, so check we find the expected commands instead [1] [2] Refs. swh/infra/sysadm-environment#4992 [1] 'defined ...' is part of the first line of the docstring for the "init" subcommand. ``` 10:21:42 E AssertionError: assert ['init', 'defined...', 'journal', 'list', 'stalled', 'storage'] == ['init', 'journal', 'list', 'stalled', 'storage'] 10:21:42 E At index 1 diff: 'defined...' != 'journal' 10:21:42 E Left contains one more item: 'storage' 10:21:42 E Full diff: 10:21:42 E - ['init', 'journal', 'list', 'stalled', 'storage'] 10:21:42 E + ['init', 'defined...', 'journal', 'list', 'stalled', 'storage'] 10:21:42 E ? ++++++++++++++ ``` [2] https://jenkins.softwareheritage.org/view/swh-debian%20(draft)/job/debian/job/packages/job/DSCRUB/job/gbp-buildpackage/31/console --- swh/scrubber/tests/test_cli.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/swh/scrubber/tests/test_cli.py b/swh/scrubber/tests/test_cli.py index 63c9e0a..74bc90b 100644 --- a/swh/scrubber/tests/test_cli.py +++ b/swh/scrubber/tests/test_cli.py @@ -88,7 +88,11 @@ def test_help_check(mocker, scrubber_db, swh_storage): assert output[0] == msg assert "Commands:" in output commands = [cmd.split()[0] for cmd in output[output.index("Commands:") + 1 :]] - assert commands == ["init", "journal", "list", "stalled", "storage"] + # With older click version (e.g. 7.0-1), the text wrapping can be different, + # resulting in some docstring text included in this command list, so check we find + # the expected commands instead + for command in ["init", "journal", "list", "stalled", "storage"]: + assert command in commands # without a config file, --help should still work but with an extra message result = CliRunner().invoke( @@ -101,7 +105,11 @@ def test_help_check(mocker, scrubber_db, swh_storage): assert output[2] == msg assert "Commands:" in output commands = [cmd.split()[0] for cmd in output[output.index("Commands:") + 1 :]] - assert commands == ["init", "journal", "list", "stalled", "storage"] + # With older click version (e.g. 7.0-1), the text wrapping can be different, + # resulting in some docstring text included in this command list, so check we find + # the expected commands instead + for command in ["init", "journal", "list", "stalled", "storage"]: + assert command in commands def test_check_init(mocker, scrubber_db, swh_storage): -- GitLab