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
Add a hook to modify final error text #10666
Labels
topic: rewrite
related to the assertion rewrite mechanism
type: proposal
proposal for a new feature, often to gather opinions or design the API around the new feature
Comments
@RonnyPfannschmidt Already explained. |
as for nice formatting, the builtin variant does quite some extra work i recommend taking a look |
Why not allow us to modify the final string? Alternatively the "extra work" can be exposed as a function to more easily implement in the current hook. |
Hookwappers may force/alter outcomes |
Not really sure what you mean. |
Zac-HD
added
type: proposal
proposal for a new feature, often to gather opinions or design the API around the new feature
topic: rewrite
related to the assertion rewrite mechanism
labels
Jan 17, 2023
# untested
@pytest.hookimpl(hookwapper=true)
def pytest_assertrepr_compare(...):
outcome = yield
Stuff.do_with(outcome) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
topic: rewrite
related to the assertion rewrite mechanism
type: proposal
proposal for a new feature, often to gather opinions or design the API around the new feature
What's the problem this feature will solve?
I have a test where I need to compare long strings.
A common failure is for spaces to be changed to tabs or other invisible characters.
I need a way to visualise invisible characters.
Describe the solution you'd like
Being able to modify the output string would enable me to replace invisible characters with visible substitutes and make debugging easier.
Concise example:
This produces:
With two lines indistinguishable because my terminal doesn't show tabs as visible characters.
Alternative Solutions
I have tried
pytest_assertrepr_compare
, but then nice formatting is gone and it is impossible to find the error in a long string.I guess, I can set my terminal to display tabs visibly, but that is not very user-friendly since that is not the default for the vast majority of people.
Additional context
TBH, might be a good idea to invisible characters using visible substitutes, e.g. "▸" for tab and "·" for space.
The text was updated successfully, but these errors were encountered: