-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes issue #2606 by making color=True behavior agnostic of Operating System. #2731
base: stable
Are you sure you want to change the base?
Conversation
Rebased to fix merge conflicts more easily. However, something seems to sometimes cause the windows version to fail. Currently investigating that. I've had it fail locally and then a second rerun succeed. I'm unsure what is causing the issue atm. |
8e34c62
to
e4d4f3c
Compare
Thank you, though this was recently fixed by #2607. |
Looks like we may have concluded that as well, and now this PR was only test changes? I can't figure out why |
After rebasing this on latest stable that includes #2607 and #2733, the |
Issue #2606 described a inconsistency in how color=True works between Operating Systems.
This is because ANSI styles can't always be applied to different terminals on windows. This did not cause issues when running it within the terminals because Colorama would change the ANSI style codes to escape codes for windows when it was required. However, if you were to pipe the
click.echo()
output to a file then theshould_strip_ansi
function would not work on Windows as the other operating systems.This is because the
auto_wrap_for_ansi
function was not being called with the color argument. After theauto_wrap_for_ansi
function is called, it defaultscolor=None
and will end up callingshould_strip_ansi
withcolor=None
which is different from the original call toshould_strip_ansi
that was called before the wrapper function.By passing color to
auto_wrap_for_ansi
, then the behavior ofshould_strip_ansi
becomes consistent.An additional change applied within the PR is to the tests in
test_utils.py
. This is to increase test coverage for the different cases ofclick.echo()
and removes the old version of the test. Instead of one test that mocksisatty()
, there are now three different tests. One that mocksisatty()=True
and_is_jupyter_kernel_output()=False
, another that mocksisatty()=False
and_is_jupyter_kernel_output()=True
, and the last one mocks bothisatty()=False
and_is_jupyter_kernel_output()=False
.fixes #2606
should fail without the change.