From 831b8a8fd9d0b36b2b696b1bd039b9b38230908e Mon Sep 17 00:00:00 2001 From: Tim Hsiung Date: Sat, 9 May 2026 20:12:19 +0800 Subject: [PATCH] test(cli): skip invalid-command snapshot on Python 3.12.0-3.12.6 Closes #1864. The reference snapshots for `test_invalid_command` reflect the no-quote argparse error format that landed in CPython 3.13 and was backported to 3.12.7 (gh-129019). On Python 3.12.0-3.12.6 argparse still prints quoted choices, so the snapshot diff fails for those patch releases. Skip the test on 3.12.0-3.12.6 with a precise `skipif` rather than maintaining a duplicate snapshot. The CI matrix already runs on recent 3.12.x where the test is exercised; users on older patches just see the test as `s` instead of a hard failure. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/test_cli.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index c1f6d5bed..d5fe0dc90 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -34,6 +34,15 @@ def test_no_argv(util: UtilFixture, capsys, file_regression): "invalidCommand", ], ) +@pytest.mark.skipif( + sys.version_info[:2] == (3, 12) and sys.version_info < (3, 12, 7), + reason=( + "argparse stopped quoting choices in 3.13 (CPython gh-129019), " + "backported to 3.12.7. The reference snapshot reflects the " + "no-quote format, so older 3.12.x patches (3.12.0-3.12.6) print " + "quoted choices and fail. See commitizen-tools/commitizen#1864." + ), +) @pytest.mark.usefixtures("python_version", "consistent_terminal_output") def test_invalid_command(util: UtilFixture, capsys, file_regression, arg): with pytest.raises(NoCommandFoundError):