GeezerVison is showing github.com — gh-131178: Add tests for `ensurepip` command-line interface by iamsharduld · Pull Request #157154 · python/cpython
Conversation
iamsharduld
commented
Sep 8, 2026
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
The documented command-line interface of ensurepip has six options, but test_ensurepip.py only called _main() with --version and with no arguments. The options themselves were covered only through bootstrap(), so a mistake in the argument parser or in how _main() forwards the parsed options would not have been caught.
This adds tests to the existing TestBootstrappingMainFunction class, one per documented option, in the same style as the TestBootstrap tests (pip is mocked, the arguments passed to pip and ENSUREPIP_OPTIONS are asserted):
--root, --user, --upgrade and -U, -v / --verbose / -vv / repeated -v
--altinstall, --default-pip, and the documented exception when both are given
- all options together, checking the order of the options does not matter
--help lists every documented option and does not run pip
- an unknown option exits with status 2 and does not run pip
Tests-only; a NEWS entry is included in the Tests section like the earlier PRs in this series that shipped one.
Ran test_ensurepip (also with -R 3:3), make patchcheck and the pre-commit hooks on macOS.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The documented options of ``python -m ensurepip`` (--upgrade, --user,
--root, --altinstall, --default-pip, --verbose) were only tested through
bootstrap(), not through the command line. Drive each one through
_main() with pip mocked, including the altinstall/default-pip conflict,
--help and an unknown option.
|
The "Sanitizers / TSan (free-threading)" failure is unrelated to this change: test_asyncio.test_taskgroups.test_taskgroup_cancel_keeps_outer_cancellation lost its cancellation message under the slow build. Reported as gh-157157 with a fix in #157158.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
iamsharduld
commented
Sep 9, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Dropped the NEWS entry: this changes only tests, which the devguide lists among the exemptions. The same point was made on #157171 ("This is a fix to unreleased test. It does not need a NEWS entry") and on #157158, so I am applying it across my open test-only PRs rather than having it raised on each one. bedevere/news will stay red until skip news is applied.
(Edited to remove two user mentions that pinged core developers for no reason. Sorry for the noise.)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
pfmoore
Awaiting requested review from pfmoore
pfmoore is a code owner
pradyunsg
Awaiting requested review from pradyunsg
pradyunsg is a code owner
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|