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

Customize pytest error message #179

Open
pedro-psb opened this issue Sep 11, 2024 · 7 comments · May be fixed by #180
Open

Customize pytest error message #179

pedro-psb opened this issue Sep 11, 2024 · 7 comments · May be fixed by #180

Comments

@pedro-psb
Copy link

Hey,
I want to request the addition of a setting to change the pytest error message. E.g:

# Current message
E       Failed: Timeout >300.0s

# What would be helpful in my context
E       [pytest-timeout] For some reason this test is hanging: Timeout >300.0s

I work on a project made of plugins where the CI is quite complex and often changes.

The pytest-timeout was introduced by the CI team and some test failed due to timeout on the plugin I was looking at.
It took some time to figure out that this was a plugin that was introduced, and a more explicit message would have been helpful.

I can submit a PR if that's ok.

@flub
Copy link
Member

flub commented Sep 12, 2024

pytest-timeout already announces itself in the reporting header like most other pytest plugins. I'm not sure I'm in favour of adding something like this, it adds maintenance complexity for very little in return. This feels more like a problem that should be solved in your CI pipeline or development communication.

@pedro-psb
Copy link
Author

If maintenance complexity is a concern, what about just changing the error message to be more explicit?
I don't disagree with any of what you said, but regardless, informative error messages are generally helpful.
IMO, the information that this was raised by the plugin is meaningful, as timeouts may have multiple sources.

@RonnyPfannschmidt
Copy link
Member

The proposed message is much better

Let's use more obnoxious Exception type names+ expand the message text

This is for beginners friendlyness

@nicoddemus
Copy link
Member

I believe @flub just misunderstood the request?

Basically just change the message from Failed: Timeout >300.0s to [pytest-timeout] For some reason this test is hanging: Timeout >300.0s (not customizable or anything).

Seems trivial and indeed better.

@pedro-psb
Copy link
Author

pedro-psb commented Sep 12, 2024

I believe @flub just misunderstood the request?

He got it right, I proposed it to be customizable at first. That was an XY problem from my side.
But yeah, the core request is to have a more informative error message title.

@nicoddemus
Copy link
Member

nicoddemus commented Sep 12, 2024 via email

@flub
Copy link
Member

flub commented Sep 19, 2024 via email

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

Successfully merging a pull request may close this issue.

4 participants