Skip to content

test: normalize argparse choice snapshots#2000

Open
puneetdixit200 wants to merge 2 commits into
commitizen-tools:masterfrom
puneetdixit200:fix-argparse-choice-snapshots
Open

test: normalize argparse choice snapshots#2000
puneetdixit200 wants to merge 2 commits into
commitizen-tools:masterfrom
puneetdixit200:fix-argparse-choice-snapshots

Conversation

@puneetdixit200
Copy link
Copy Markdown

Description

Fixes #1990 by normalizing only the volatile argparse (choose from ...) choice list before the invalid-command snapshot assertion. This lets the invalidCommand parametrization run again on Python 3.14.5+, while keeping the command failure, usage output, and invalid value covered.

Checklist

Was generative AI tooling used to co-author this PR?

  • Yes (OpenAI GPT-5)

Generated-by: OpenAI GPT-5 following the guidelines

Code Changes

  • Add test cases to all the changes you introduce
  • Run uv run poe all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Documentation Changes

No documentation changes.

  • Run uv run poe doc locally to ensure the documentation pages renders correctly
  • Check and fix any broken links (internal or external)

Expected Behavior

tests/test_cli.py::test_invalid_command[invalidCommand] should pass across Python patch releases that differ only in whether argparse quotes the choose from entries.

Steps to Test This Pull Request

  1. UV_CACHE_DIR=$PWD/.uv-cache UV_PROJECT_ENVIRONMENT=$PWD/.venv314 uv run --python python3.14 --group test pytest tests/test_cli.py::test_normalize_argparse_choice_quotes tests/test_cli.py::test_invalid_command -q
  2. UV_CACHE_DIR=$PWD/.uv-cache UV_PROJECT_ENVIRONMENT=$PWD/.venv314 uv run --python python3.14 ruff check tests/test_cli.py
  3. UV_CACHE_DIR=$PWD/.uv-cache UV_PROJECT_ENVIRONMENT=$PWD/.venv314 uv run --python python3.14 ruff format --check tests/test_cli.py
  4. git diff --check

Additional Context

I did not run the full uv run poe all suite locally because this change is isolated to tests/test_cli.py and the targeted Python 3.14.5 regression plus ruff checks cover the changed behavior.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.24%. Comparing base (c3f6797) to head (2d26580).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2000   +/-   ##
=======================================
  Coverage   98.24%   98.24%           
=======================================
  Files          61       61           
  Lines        2785     2785           
=======================================
  Hits         2736     2736           
  Misses         49       49           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: test_invalid_command[py_3.14-invalidCommand] fails on Python 3.14.5 due to argparse quoting change

1 participant