From 695140d57d1d0517417a9405584bf6e26f0b3cfc Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Mon, 12 Oct 2020 14:58:16 +0300 Subject: [PATCH] Save exceptions in the main thread in excQueue --- src/tests/core.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tests/core.py b/src/tests/core.py index 85b2cc8b..ac1f9e7a 100644 --- a/src/tests/core.py +++ b/src/tests/core.py @@ -8,6 +8,7 @@ import pickle # nosec import Queue import random # nosec import string +import sys import time import unittest @@ -250,4 +251,11 @@ def run(): else: qt_tests = loader.loadTestsFromModule(bitmessageqt.tests) suite.addTests(qt_tests) + + def keep_exc(ex_cls, exc, tb): # pylint: disable=unused-argument + """Own exception hook for test cases""" + excQueue.put(('tests', exc)) + + sys.excepthook = keep_exc + return unittest.TextTestRunner(verbosity=2).run(suite)