Skip to content

fix: handle argparse changes in Python 3.14#661

Merged
mayeut merged 2 commits intopypa:mainfrom
cjwatson:py314-argparse
Jan 3, 2026
Merged

fix: handle argparse changes in Python 3.14#661
mayeut merged 2 commits intopypa:mainfrom
cjwatson:py314-argparse

Conversation

@cjwatson
Copy link
Copy Markdown
Contributor

python/cpython#66436 causes tests/unit/test_main.py::test_help to fail on Python 3.14 as follows:

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f549ac59a70>, capsys = <_pytest.capture.CaptureFixture object at 0x7f549ad9e660>

    @on_supported_platform
    def test_help(monkeypatch, capsys):
        # GIVEN
        monkeypatch.setattr(sys, "argv", ["auditwheel"])

        # WHEN
        retval = main()

        # THEN
        assert retval is None
        captured = capsys.readouterr()
>       assert "usage: auditwheel [-h] [-V] [-v] command ..." in captured.out
E       assert 'usage: auditwheel [-h] [-V] [-v] command ...' in "usage: python3.14 -m pytest [-h] [-V] [-v] command ...\n\nCross-distro Python wheels.\n\npositional arguments:\n  command\n    show         Audit a wheel for external shared library dependencies.\n    repair       Vendor in external shared library dependencies of a wheel. If\n                 multiple wheels are specified, an error processing one wheel\n                 will abort processing of subsequent wheels.\n    lddtree      Analyze a single ELF file (similar to ``ldd``).\n\noptions:\n  -h, --help     show this help message and exit\n  -V, --version  show program's version number and exit\n  -v, --verbose  Give more output. Option is additive\n"
E        +  where "usage: python3.14 -m pytest [-h] [-V] [-v] command ...\n\nCross-distro Python wheels.\n\npositional arguments:\n  command\n    show         Audit a wheel for external shared library dependencies.\n    repair       Vendor in external shared library dependencies of a wheel. If\n                 multiple wheels are specified, an error processing one wheel\n                 will abort processing of subsequent wheels.\n    lddtree      Analyze a single ELF file (similar to ``ldd``).\n\noptions:\n  -h, --help     show this help message and exit\n  -V, --version  show program's version number and exit\n  -v, --verbose  Give more output. Option is additive\n" = CaptureResult(out="usage: python3.14 -m pytest [-h] [-V] [-v] command ...\n\nCross-distro Python wheels.\n\npositional arguments:\n  command\n    show         Audit a wheel for external shared library dependencies.\n    repair       Vendor in external shared library dependencies of a wheel. If\n                 multiple wheels are specified, an error processing one wheel\n                 will abort processing of subsequent wheels.\n    lddtree      Analyze a single ELF file (similar to ``ldd``).\n\noptions:\n  -h, --help     show this help message and exit\n  -V, --version  show program's version number and exit\n  -v, --verbose  Give more output. Option is additive\n", err='').out

tests/unit/test_main.py:41: AssertionError

Monkey-patch things a bit harder so that the output is as we expect.

python/cpython#66436 causes
`tests/unit/test_main.py::test_help` to fail on Python 3.14 as follows:

```
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f549ac59a70>, capsys = <_pytest.capture.CaptureFixture object at 0x7f549ad9e660>

    @on_supported_platform
    def test_help(monkeypatch, capsys):
        # GIVEN
        monkeypatch.setattr(sys, "argv", ["auditwheel"])

        # WHEN
        retval = main()

        # THEN
        assert retval is None
        captured = capsys.readouterr()
>       assert "usage: auditwheel [-h] [-V] [-v] command ..." in captured.out
E       assert 'usage: auditwheel [-h] [-V] [-v] command ...' in "usage: python3.14 -m pytest [-h] [-V] [-v] command ...\n\nCross-distro Python wheels.\n\npositional arguments:\n  command\n    show         Audit a wheel for external shared library dependencies.\n    repair       Vendor in external shared library dependencies of a wheel. If\n                 multiple wheels are specified, an error processing one wheel\n                 will abort processing of subsequent wheels.\n    lddtree      Analyze a single ELF file (similar to ``ldd``).\n\noptions:\n  -h, --help     show this help message and exit\n  -V, --version  show program's version number and exit\n  -v, --verbose  Give more output. Option is additive\n"
E        +  where "usage: python3.14 -m pytest [-h] [-V] [-v] command ...\n\nCross-distro Python wheels.\n\npositional arguments:\n  command\n    show         Audit a wheel for external shared library dependencies.\n    repair       Vendor in external shared library dependencies of a wheel. If\n                 multiple wheels are specified, an error processing one wheel\n                 will abort processing of subsequent wheels.\n    lddtree      Analyze a single ELF file (similar to ``ldd``).\n\noptions:\n  -h, --help     show this help message and exit\n  -V, --version  show program's version number and exit\n  -v, --verbose  Give more output. Option is additive\n" = CaptureResult(out="usage: python3.14 -m pytest [-h] [-V] [-v] command ...\n\nCross-distro Python wheels.\n\npositional arguments:\n  command\n    show         Audit a wheel for external shared library dependencies.\n    repair       Vendor in external shared library dependencies of a wheel. If\n                 multiple wheels are specified, an error processing one wheel\n                 will abort processing of subsequent wheels.\n    lddtree      Analyze a single ELF file (similar to ``ldd``).\n\noptions:\n  -h, --help     show this help message and exit\n  -V, --version  show program's version number and exit\n  -v, --verbose  Give more output. Option is additive\n", err='').out

tests/unit/test_main.py:41: AssertionError
```

Monkey-patch things a bit harder so that the output is as we expect.
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.24%. Comparing base (4490469) to head (d20569e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #661   +/-   ##
=======================================
  Coverage   95.24%   95.24%           
=======================================
  Files          22       22           
  Lines        1829     1829           
  Branches      343      343           
=======================================
  Hits         1742     1742           
  Misses         48       48           
  Partials       39       39           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread tests/unit/test_main.py
Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com>
@mayeut mayeut merged commit afb4e53 into pypa:main Jan 3, 2026
21 of 31 checks passed
@mayeut mayeut mentioned this pull request Jan 4, 2026
@cjwatson cjwatson deleted the py314-argparse branch January 5, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants