We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Consider the code below: The line Error 1 should appear in the stderr, but only Error 2 appears.
Error 1
Error 2
This happens because exceptions.format_captured_exceptions is a custom exception printer that doesn't take into account the exception cause.
exceptions.format_captured_exceptions
from pytestqt.qt_compat import qt_api class MyWidget(qt_api.QWidget): def method(self): raise RuntimeError('Error 1') def event(self, ev): called.append(1) try: self.method() finally: raise RuntimeError('Error 2') weak_ref = None called = [] def test_1(qapp): global weak_ref w = MyWidget() qapp.postEvent(w, qt_api.QEvent(qt_api.QEvent.User)) qapp.processEvents() assert len(called) > 0 w.deleteLater()
The text was updated successfully, but these errors were encountered:
Changing format_captured_exceptions to the code below seems to fix it for me.
format_captured_exceptions
def format_captured_exceptions(exceptions): """ Formats exceptions given as (type, value, traceback) into a string suitable to display as a test failure. """ if sys.version_info[0] <= 2: message = 'Qt exceptions in virtual methods:\n' message += '_' * 80 + '\n' for (exc_type, value, tback) in exceptions: message += ''.join(traceback.format_tb(tback)) + '\n' message += '%s: %s\n' % (exc_type.__name__, value) message += '_' * 80 + '\n' return message else: from io import StringIO message = StringIO() message.write('Qt exceptions in virtual methods:\n') message.write('_' * 80 + '\n') for (exc_type, value, tback) in exceptions: traceback.print_exception(exc_type, value, tback, file=message) message.write('_' * 80 + '\n') return message.getvalue()
Sorry, something went wrong.
Thanks for the report and sample code @fabioz! I plan to tackle this soon.
Properly handle Python 3 chained exceptions in format_captured_except…
06eda3b
…ions Fix pytest-dev#215
No branches or pull requests
Consider the code below: The line
Error 1
should appear in the stderr, but onlyError 2
appears.This happens because
exceptions.format_captured_exceptions
is a custom exception printer that doesn't take into account the exception cause.The text was updated successfully, but these errors were encountered: