diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2016-10-27 21:15:05 -0200 |
---|---|---|
committer | Bruno Oliveira <nicoddemus@gmail.com> | 2016-11-03 10:48:43 -0200 |
commit | 006a901b861e9de28daf11ab4b10b87bed18aba1 (patch) | |
tree | 4f3ac557bc91955fb8a31861efdde7cecd1820c8 /_pytest | |
parent | 45b21fa9b0478610bc54190fe3ade31a5f3b2f16 (diff) | |
download | pytest-006a901b861e9de28daf11ab4b10b87bed18aba1.tar.gz |
Properly handle exceptions in multiprocessing tasks
Fix #1984
Diffstat (limited to '_pytest')
-rw-r--r-- | _pytest/_code/code.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py index 30e12940b..416ee0b1b 100644 --- a/_pytest/_code/code.py +++ b/_pytest/_code/code.py @@ -623,16 +623,23 @@ class FormattedExcinfo(object): e = excinfo.value descr = None while e is not None: - reprtraceback = self.repr_traceback(excinfo) - reprcrash = excinfo._getreprcrash() + if excinfo: + reprtraceback = self.repr_traceback(excinfo) + reprcrash = excinfo._getreprcrash() + else: + # fallback to native repr if the exception doesn't have a traceback: + # ExceptionInfo objects require a full traceback to work + reprtraceback = ReprTracebackNative(py.std.traceback.format_exception(type(e), e, None)) + reprcrash = None + repr_chain += [(reprtraceback, reprcrash, descr)] if e.__cause__ is not None: e = e.__cause__ - excinfo = ExceptionInfo((type(e), e, e.__traceback__)) + excinfo = ExceptionInfo((type(e), e, e.__traceback__)) if e.__traceback__ else None descr = 'The above exception was the direct cause of the following exception:' elif e.__context__ is not None: e = e.__context__ - excinfo = ExceptionInfo((type(e), e, e.__traceback__)) + excinfo = ExceptionInfo((type(e), e, e.__traceback__)) if e.__traceback__ else None descr = 'During handling of the above exception, another exception occurred:' else: e = None |