GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-131178: Add tests for `ensurepip` command-line interface by iamsharduld · Pull Request #157154 · python/cpython

Conversation

@iamsharduld

@iamsharduld iamsharduld commented Sep 8, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

  • Issue: Add tests for command-line interface #131178

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iamsharduld
pythongh-131178: Add tests for ensurepip command-line interface
00166c3
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.
@iamsharduld
iamsharduld requested review from pfmoore and pradyunsg as code owners September 8, 2026 03:47
@bedevere-app bedevere-app Bot mentioned this pull request Sep 8, 2026
Add tests for command-line interface #131178
Open
7 of 9 tasks
@bedevere-app bedevere-app Bot added tests Tests in the Lib/test dir awaiting review labels Sep 8, 2026
@iamsharduld

iamsharduld commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iamsharduld
Remove the NEWS entry
2b8f3af
@iamsharduld

iamsharduld commented Sep 9, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@pfmoore pfmoore Awaiting requested review from pfmoore pfmoore is a code owner
@pradyunsg 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

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

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.

1 participant

@iamsharduld
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.