Skip to content

Commit a1c6435

Browse files
committed
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 <guillem@meta.com>
1 parent 6570c13 commit a1c6435

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/scancode/test_cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,12 @@ def test_scan_errors_out_with_unknown_option():
730730
test_file = test_env.get_test_loc('license_text/test.txt')
731731
args = ['--json--info', test_file]
732732
result = run_scan_click(args, expected_rc=2)
733-
assert 'Error: No such option: --json--info'.lower() in result.output.lower()
733+
# Accept both the old and new click error message formats:
734+
# click < 8.2: "Error: No such option: --json--info"
735+
# click >= 8.2: "Error: No such option '--json--info'. (Did you mean ...)"
736+
output = result.output.lower()
737+
assert 'no such option' in output
738+
assert '--json--info' in output
734739

735740

736741
def test_scan_to_json_without_FILE_does_not_write_to_next_option():

0 commit comments

Comments
 (0)