-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
better reporting for python 3.3+ chained exceptions #138
Comments
Pytest.raises also does not support this, in that if the inner and outer exceptions are different, and you use pytest.raises(SpecificError), it only matches the outer one. I guess that is correct?? but as mentioned the assert output could be nicer. Example:
test_attributesValueError fails. (tested on py27 and py34) |
@pfctdayelise that's indeed the behaviour I'd expect - it's essentially the same thing try/except does as well. After all, the handled exception is never really raised. |
this is blocked by #103 |
What is the status of the issue? As far as I understand #103 has been resolved. |
yes, nobody found time to work on this one however - we wouldn't mind ahelping hand |
Alright, I'd be glad to chime in. But I need some time to dig into FormattedExcinfo |
@roolebo, Thanks! Feel free to ask here or in the mailing list for help. |
I've been actively looking into the issue for the last couple days. If someone badly needs full traceback with chained exceptions, please use native traceback for now: |
@roolebo nice, thanks! |
@nicoddemus is there a way to see output of print statements for debug purpose? I use tox to run tests: The current idea to address the issue is to add new repr for exception chains to maintain compatibility with older versions of Python:
|
Hey @roolebo, you can pass extra parameters to
|
@nicoddemus Thanks! That helped a lot. I'd like to discuss the visual appearance of an exception chain. I made a test case:
py.test with my fix makes the following report:
Is it okay to have such bold separators between elements of an exception chain? Do you have any other advices on visual appearance of the delimiter (colors, etc)? |
TBH I find that separator a little too disruptive... I would use Python's example and just use empty lines as separator. As far as color goes, I would use something other than red, perhaps Cyan (light blue)? |
@nicoddemus I tried first without separator and color, the border between exceptions wasn't visually clear. Yeah, I agree, a color might be more than enough. I tried both cyan and yellow, and the latter looks much better to me: |
Thanks for the screenshots. LGTM! 😁 Make sure to add those screenshots to your PR! |
@nicoddemus Thanks. I still have 7 tests failing :) Most of them are concerned about lack of |
Yes, because other code (plugins and conftests) depend on that API. I know I do in pytest-qt, and I'm pretty sure pytest-catchlog depends as well. |
@nicoddemus Alright, thanks for the details. I made common base class with addsection method for both ReprExceptionInfo and ExceptionChainRepr. What about reprtraceback? Should I store reprtraceback of the outermost(newest) exception? |
Hmm at this point I think it is more productive for us to discuss details over the code itself, so I think it would be a good time to open a PR now. Btw, the naming seems inconsistent... ideally it should be either |
Fix issue #138 - support chained exceptions
Parse complex expressions in parameters after * and **
Fix pytest-devpi-server test on py34 updating "ruamel.yaml" requirements
Is there any update on this? I am not seeing chained exceptions in latest pytest with python 3.12 I also tried all possible |
Originally reported by: Anonymous
With Python 3, py.test doesn't propery display exception chains. The following script
when run with Python 3.2 properly outputs the exception chain:
but when run unter py.test only the outermost exception is displayed:
The text was updated successfully, but these errors were encountered: