Repository navigation
Conversation
kdeldycke
force-pushed
the
clirunner-context-settings
branch
from
October 26, 2026 09:58
e3a1b8d to
6140c6b
Compare
kdeldycke
force-pushed
the
clirunner-context-settings
branch
from
October 26, 2026 10:14
6140c6b to
ee07b7c
Compare
kdeldycke
added a commit
to kdeldycke/click-extra
that referenced
this pull request
Oct 26, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds a
context_settingsparameter toCliRunner.invoke(), allowing tests to pass context-specific settings to the command'sContext.CliRunner.invoke()passes its extra keyword arguments to theContextof the command, exceptcolor: its owncolorparameter takes that name.context_settingssolves this collision. And now a test can set what its terminal supports, as well as thecolorof the context in the same call.With this addition, I can now test cases that were previously difficult or impossible to cover, such as verifying how the command behaves with different
Contextsettings.This was proposed 5 years ago in #2110 but at that time this change was evaluated as niche. Since then, we did a lot of color handling improvements in Click (#3505, #3653, #3739) which added a lot of color-related tests, so this is no longer a niche concern.
For evidence, I used the new
context_settingsparameter to extend and simplify existing checks. Seetest_prompt_and_confirm_ansi_respects_colorandtest_tempfile_pager_handles_ansi.