Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Setting color=True in runner.invoke on windows strips ansi codes #2705

Closed
LilyFoote opened this issue Apr 11, 2024 · 2 comments · Fixed by #2729
Closed

Setting color=True in runner.invoke on windows strips ansi codes #2705

LilyFoote opened this issue Apr 11, 2024 · 2 comments · Fixed by #2729
Milestone

Comments

@LilyFoote
Copy link

I am trying to test that a click command uses colors correctly. I've set the color=True argument to runner.invoke and this keeps the ansi escape codes as expected on Linux. However, on Windows these are completely stripped, as if color=False was set.

I did see #2606 and #2607, but testing the change there isn't enough to fix this for me. I think the problem is that color=True isn't set in the Context on Windows and therefore ctx.color is still None in resolve_color_default, despite color=True being passed to invoke.

Environment:

  • Python version: 3.8 - 3.12
  • Click version: 8.1.7
@Tyl13
Copy link
Contributor

Tyl13 commented May 20, 2024

Will look into this issue. If I can't reproduce your issue, what is the version of Windows you are using?

@LilyFoote
Copy link
Author

I was seeing this with the windows-latest runner in github actions.

Tyl13 added a commit to Tyl13/click that referenced this issue May 21, 2024
@aenglander aenglander linked a pull request May 21, 2024 that will close this issue
4 tasks
@davidism davidism added this to the 8.1.8 milestone May 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 5, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants