Skip to content

Commit 21bef10

Browse files
author
Lee Miller
committed
Improve the base class for bitmessageqt test cases
1 parent a71b44e commit 21bef10

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

src/bitmessageqt/tests/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""bitmessageqt tests"""
22

3-
from addressbook import TestAddressbook
4-
from main import TestMain, TestUISignaler
5-
from settings import TestSettings
6-
from support import TestSupport
3+
from .addressbook import TestAddressbook
4+
from .main import TestMain, TestUISignaler
5+
from .settings import TestSettings
6+
from .support import TestSupport
77

88
__all__ = [
99
"TestAddressbook", "TestMain", "TestSettings", "TestSupport",

src/bitmessageqt/tests/main.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
"""Common definitions for bitmessageqt tests"""
22

3-
import Queue
43
import sys
54
import unittest
65

76
from PyQt4 import QtCore, QtGui
7+
from six.moves import queue
88

99
import bitmessageqt
10-
import queues
11-
from tr import _translate
10+
from bitmessageqt import _translate, config, queues
1211

1312

1413
class TestBase(unittest.TestCase):
1514
"""Base class for bitmessageqt test case"""
1615

16+
@classmethod
17+
def setUpClass(cls):
18+
"""Provide the UI test cases with common settings"""
19+
cls.config = config
20+
1721
def setUp(self):
1822
self.app = (
1923
QtGui.QApplication.instance()
@@ -24,14 +28,21 @@ def setUp(self):
2428
self.window.appIndicatorInit(self.app)
2529

2630
def tearDown(self):
31+
"""Search for exceptions in closures called by timer and fail if any"""
2732
# self.app.deleteLater()
33+
concerning = []
2834
while True:
2935
try:
3036
thread, exc = queues.excQueue.get(block=False)
31-
except Queue.Empty:
32-
return
37+
except queue.Empty:
38+
break
3339
if thread == 'tests':
34-
self.fail('Exception in the main thread: %s' % exc)
40+
concerning.append(exc)
41+
if concerning:
42+
self.fail(
43+
'Exceptions found in the main thread:\n%s' % '\n'.join((
44+
str(e) for e in concerning
45+
)))
3546

3647

3748
class TestMain(unittest.TestCase):

0 commit comments

Comments
 (0)