What's the problem this feature will solve?
I've got a test similar to the following with a nested exception:
def raise_something():
raise TypeError()
def test_something():
try:
raise_something()
except TypeError:
raise ValueError()
Running the test produces:
def raise_something():
> raise TypeError()
E TypeError
test.py:2: TypeError
During handling of the above exception, another exception occurred:
def test_something():
try:
raise_something()
except TypeError:
> raise ValueError()
E ValueError
test.py:9: ValueError
I'd like to be able to inspect the stack where raise_something() failed. Best I can tell, that context is unreachable.
If I use --pdb, the code breaks at test.py:9 with the ValueError, but by the time pytest has handled the error, sys.exc_info() no longer points to the execution context where the failure occurred, but instead may be (None, None, None) or perhaps an unrelated context like (<class 'AttributeError'>, AttributeError("'PytestPdbWrapper' object has no attribute 'do_sys'"), <traceback object at 0x101f26c40>). Therefore, I'm unable to take advantages of techniques to trace to the inner exception stack.
Describe the solution you'd like
In the pdb context or in a global variable or in some other way, expose the original unhandled exception context.
What's the problem this feature will solve?
I've got a test similar to the following with a nested exception:
Running the test produces:
I'd like to be able to inspect the stack where
raise_something()failed. Best I can tell, that context is unreachable.If I use
--pdb, the code breaks at test.py:9 with theValueError, but by the time pytest has handled the error,sys.exc_info()no longer points to the execution context where the failure occurred, but instead may be(None, None, None)or perhaps an unrelated context like(<class 'AttributeError'>, AttributeError("'PytestPdbWrapper' object has no attribute 'do_sys'"), <traceback object at 0x101f26c40>). Therefore, I'm unable to take advantages of techniques to trace to the inner exception stack.Describe the solution you'd like
In the pdb context or in a global variable or in some other way, expose the original unhandled exception context.