From a1c6435375866ae2fead2df2c967f2ba150f18e9 Mon Sep 17 00:00:00 2001 From: Guillem Serra Cazorla Date: Mon, 18 May 2026 14:19:39 +0100 Subject: [PATCH] Make 'no such option' assertion tolerant of newer click error format click >= 8.2 changed the unknown-option error message from 'Error: No such option: --foo' to 'Error: No such option '--foo'. (Did you mean ...)' This broke tests/scancode/test_cli.py::test_scan_errors_out_with_unknown_option on the *_latest_from_pip CI matrix (ubuntu22/24, macos14, win2019/2022). Relax the assertion to check for the stable substrings ('no such option' and the offending option name) instead of the exact phrasing, so the test works with both click < 8.2 and click >= 8.2. Signed-off-by: Guillem Serra Cazorla --- tests/scancode/test_cli.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/scancode/test_cli.py b/tests/scancode/test_cli.py index 858baf68ca..9d038f71e6 100644 --- a/tests/scancode/test_cli.py +++ b/tests/scancode/test_cli.py @@ -730,7 +730,12 @@ def test_scan_errors_out_with_unknown_option(): test_file = test_env.get_test_loc('license_text/test.txt') args = ['--json--info', test_file] result = run_scan_click(args, expected_rc=2) - assert 'Error: No such option: --json--info'.lower() in result.output.lower() + # Accept both the old and new click error message formats: + # click < 8.2: "Error: No such option: --json--info" + # click >= 8.2: "Error: No such option '--json--info'. (Did you mean ...)" + output = result.output.lower() + assert 'no such option' in output + assert '--json--info' in output def test_scan_to_json_without_FILE_does_not_write_to_next_option():