Skip to content
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

ClickException message without color would be helpful #2419

Open
kriswuollett opened this issue Dec 20, 2022 · 0 comments
Open

ClickException message without color would be helpful #2419

kriswuollett opened this issue Dec 20, 2022 · 0 comments

Comments

@kriswuollett
Copy link

Similar to how some runtime environments don't support colors, it may be helpful to programmers that the non-colorized rendering of the ClickException message was available... something I was thinking when encountering and working around #2193.

Color shouldn't matter, nor should creating subclasses be necessary for verifying that the correct user-facing ClickException was raised with a certain message, for example in a test:

"""Tests for ClickException and exception handling."""
import click

def test_exception_message_no_color():
    """Base Exception message should be plain text."""
    exception = click.ClickException(click.style('red', fg='red') + ' text')

    assert 'red text' in str(exception) # fails currently

I'd think that __str__, and the possibly the message property too, should be rendered as plain text. I do have a simple StringIO patch that works, as well as just creating a subclass for my code if click is unpatched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant