question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can pytest show all arguments of exception that unintentionally occured?

See original GitHub issue

I have got Exception class looking like that:

class MutationValidationError(ValidationError):
    def __init__(self, error_dict=None):
        if error_dict is None:
            error_dict = ErrorDict()
        self.error_dict = error_dict
        super().__init__(msg='Failed to run mutation')

This Error is raised during test in a place where it shouldn’t. But for purpose of debugging it is crucial for me to see the contents of error_dict. Unfortunatelly it isn’t visible in test output. Can I make it visible without using try…catch clause?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Dec 24, 2018

oh I see, didn’t notice you were overriding __str__ (which would hide the value there)

0reactions
jacek-jablonskicommented, Dec 24, 2018

Thanks @asottile. Without str all arguments of Exception are visible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Reference — pytest documentation
PathLike[str]]]) – List of command line arguments. ... Use pytest.raises as a context manager, which will capture the exception of the given type:....
Read more >
How to properly assert that an exception gets raised in pytest?
Using pytest.raises is likely to be better for cases where you are testing exceptions your own code is deliberately raising, whereas using @ ......
Read more >
Confusion between message and match parameters in pytest ...
After analyzing several code bases, it appears there is frequent confusion by users between the match and message parameters in ...
Read more >
pytest Documentation - Read the Docs
pytest will run all files of the form test_*.py or *_test.py in the ... pytest --fixtures # show available builtin function arguments.
Read more >
pytest: testing exceptions (beginner - intermediate) anthony ...
today I talk about how to test exceptions in pytest ! ... If you have any suggestions or things you'd like to see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found