-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Creating a custom error report/traceback? #3586
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
Comments
Hi @michaelboulton, I would start with Hope this helps! |
You can use that as an example! 👍 |
For anyone else who comes along this, we've used the above as inspiration along with Pyyaml to get some metadata about the input data for the output. For example showing a missing input variable: Thanks for the help! |
Thanks for the follow up! 👍 |
I've got a pytest plugin that loads files from YAML and generates tests from it (https://github.com/taverntesting/tavern/blob/master/tavern/testutils/pytesthook.py), inspired by the example in the pytest documentation. It loads the tests into a subclass of
pytest.Item
and overridesruntest
to run the tests, andreportinfo
to give a hint as to which test it is in the pytest output.A test might look like this:
but currently a test failure will look like this (using
--tb=short
, otherwise it's several hundred lines long):I want to make this better so it can print out the input YAML and which line caused the failure etc, rather than printing out the traceback from the pytest run. Perhaps so that it looks more like this (just an example of the kind of thing I'm trying to do, there could actually be multiple lines which caused an error):
I'm not really sure where to even start doing this however, I've gone through the pytest source code a bit and there's quite a few places where it handles outputting the errors:
TerminalReporter
repr_failure
on theItem
pytest_runtest_logreport
hookTo be clear, I don't want to mess around with the assertion rewriting, I just want to get the final output traceback in a format that's easier to understand for an end user by showing where in the input caused the failure. I also don't want to do something like
pytest-html
that just generates an external error report based on the result of the test runs.The text was updated successfully, but these errors were encountered: