Title: test: test_invalid_command[py_3.14-invalidCommand] fails on Python 3.14.5 due to argparse quoting change · Issue #1990 · commitizen-tools/commitizen · GitHub
Open Graph Title: test: test_invalid_command[py_3.14-invalidCommand] fails on Python 3.14.5 due to argparse quoting change · Issue #1990 · commitizen-tools/commitizen
X Title: test: test_invalid_command[py_3.14-invalidCommand] fails on Python 3.14.5 due to argparse quoting change · Issue #1990 · commitizen-tools/commitizen
Description: Description The tests/test_cli.py::test_invalid_command[py_3.14-invalidCommand] test started failing on Python 3.14.5 (released May 10, 2026) because CPython restored quoting of choices in argparse error messages: gh-130750: Restore quot...
Open Graph Description: Description The tests/test_cli.py::test_invalid_command[py_3.14-invalidCommand] test started failing on Python 3.14.5 (released May 10, 2026) because CPython restored quoting of choices in argparse...
X Description: Description The tests/test_cli.py::test_invalid_command[py_3.14-invalidCommand] test started failing on Python 3.14.5 (released May 10, 2026) because CPython restored quoting of choices in argparse...
Opengraph URL: https://github.com/commitizen-tools/commitizen/issues/1990
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test: test_invalid_command[py_3.14-invalidCommand] fails on Python 3.14.5 due to argparse quoting change","articleBody":"## Description\n\nThe `tests/test_cli.py::test_invalid_command[py_3.14-invalidCommand]` test started failing on Python 3.14.5 (released [May 10, 2026](https://www.python.org/downloads/release/python-3145/)) because CPython restored quoting of choices in argparse error messages:\n\n\u003e [gh-130750](https://github.com/python/cpython/issues/130750): Restore quoting of choices in [argparse](https://docs.python.org/3.14/library/argparse.html#module-argparse) error messages for improved clarity and consistency with documentation.\n\u003e -- [3.14.5 changelog](https://docs.python.org/3.14/whatsnew/changelog.html#python-3-14-5-final)\n\n| Python | argparse \"invalid choice\" format |\n| --- | --- |\n| 3.10, 3.11 | `(choose from 'init', 'commit', ...)` (quoted) |\n| 3.12 | mixed |\n| 3.13, 3.14.0–3.14.4 | `(choose from init, commit, ...)` (unquoted) |\n| 3.14.5+ | `(choose from 'init', 'commit', ...)` (quoted, restored) |\n\nThe checked-in fixture `tests/test_cli/test_invalid_command_py_3_14_invalidCommand_.txt` was generated against 3.14.4 (unquoted), so it no longer matches.\n\n## Reproduction\n\n```bash\nuv run pytest tests/test_cli.py::test_invalid_command\n```\n\nMaster's last successful CI run was on 2026-05-09 (commit `1eb8cde6`) when the GitHub-hosted runner still had Python 3.14.4; runs on or after 2026-05-11 fail with the diff below.\n\n## Observed failure\n\n```\nFAILED tests/test_cli.py::test_invalid_command[py_3.14-invalidCommand] - AssertionError: FILES DIFFER\n-cz: error: argument {...}: invalid choice: 'invalidCommand' (choose from init, commit, ...)\n+cz: error: argument {...}: invalid choice: 'invalidCommand' (choose from 'init', 'commit', ...)\n```\n\nFull log: https://github.com/commitizen-tools/commitizen/actions/runs/25649120897/job/75283769681\n\n## Scope\n\nOnly the **1** `test_invalid_command_py_3_14_invalidCommand_.txt` fixture is affected by gh-130750 (the companion `--invalid-arg` case uses the metavar, not the choice list). The other 60+ Python-version-keyed fixtures (`test_command_shows_description_when_use_help_option_py_3_*_*.txt`, `test_no_argv_py_3_*_.txt`) capture argparse **help text**, which is unaffected by this change.\n\n## Suggested fix (short-term)\n\n**Skip the affected `test_invalid_command` parametrization on Python ≥ 3.14.5** until upstream stabilizes:\n\n```python\n@pytest.mark.parametrize(\n \"arg\",\n [\n \"--invalid-arg\",\n pytest.param(\n \"invalidCommand\",\n marks=pytest.mark.skipif(\n (3, 14, 5) \u003c= sys.version_info \u003c (3, 15),\n reason=(\n \"argparse error format changed in Python 3.14.5 (gh-130750); \"\n \"fixture matches 3.14.0-4 unquoted format\"\n ),\n ),\n ),\n ],\n)\n```\n\nSurfaced while working on #1846; this skip unblocks CI without changing PR scope. Implemented in #1991.\n\n## Future enhancement (still open after #1991)\n\nArgparse error output has churned across Python patch releases (3.10/3.11 quoted → 3.13/3.14.0–4 unquoted → 3.14.5 quoted). A more durable approach worth considering once the codebase is more stable:\n\n**Normalize argparse error output before `file_regression.check()`** — e.g., strip surrounding quotes around `choose from` items, or replace the variable parts with placeholders:\n\n```python\ndef _normalize_argparse_error(text: str) -\u003e str:\n # Collapse \"'init', 'commit'\" and \"init, commit\" to a single canonical form\n text = re.sub(\n r\"\\(choose from [^)]+\\)\",\n \"(choose from \u003cCHOICES\u003e)\",\n text,\n )\n return text\n\n# Usage:\nfile_regression.check(_normalize_argparse_error(err), extension=\".txt\")\n```\n\nThat would let us delete the per-Python-version fixtures for `test_invalid_command[invalidCommand]` and stop chasing argparse formatting changes. **#1991 only implements the short-term skip; this enhancement is still open.**","author":{"url":"https://github.com/bearomorphism","@type":"Person","name":"bearomorphism"},"datePublished":"2026-05-11T03:50:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1990/commitizen/issues/1990"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:692af0e3-7759-9c73-a1ed-71eb13360526 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A18A:134A7F:181765E:232D4CC:6A4E54DA |
| html-safe-nonce | 6af40be67214d9a0125fecff817d3180472aaa33f5358ba2bb8bc7d1e1fd7dfe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMThBOjEzNEE3RjoxODE3NjVFOjIzMkQ0Q0M6NkE0RTU0REEiLCJ2aXNpdG9yX2lkIjoiNDAwNzM0NjYyNTQ3MTAwODkwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 18686b3182befa6e5e4fc57cff13679aa391fbca3fcf3b14819465430085b20e |
| hovercard-subject-tag | issue:4417945230 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/commitizen-tools/commitizen/1990/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ef6b1f0e3e3d0d47413e02b7bcec69749c016f3cd2e4ab8cb3d4d449cf275814/commitizen-tools/commitizen/issues/1990 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ef6b1f0e3e3d0d47413e02b7bcec69749c016f3cd2e4ab8cb3d4d449cf275814/commitizen-tools/commitizen/issues/1990 |
| og:image:alt | Description The tests/test_cli.py::test_invalid_command[py_3.14-invalidCommand] test started failing on Python 3.14.5 (released May 10, 2026) because CPython restored quoting of choices in argparse... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bearomorphism |
| hostname | github.com |
| expected-hostname | github.com |
| None | 030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git |
| octolytics-dimension-user_id | 62252524 |
| octolytics-dimension-user_login | commitizen-tools |
| octolytics-dimension-repository_id | 106127589 |
| octolytics-dimension-repository_nwo | commitizen-tools/commitizen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 106127589 |
| octolytics-dimension-repository_network_root_nwo | commitizen-tools/commitizen |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f344f1eab54fc7dfc02d0d018cda7e158c3db65c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width