Improve the base class for bitmessageqt test cases
This commit is contained in:
parent
a71b44e95c
commit
21bef1058d
|
@ -1,9 +1,9 @@
|
|||
"""bitmessageqt tests"""
|
||||
|
||||
from addressbook import TestAddressbook
|
||||
from main import TestMain, TestUISignaler
|
||||
from settings import TestSettings
|
||||
from support import TestSupport
|
||||
from .addressbook import TestAddressbook
|
||||
from .main import TestMain, TestUISignaler
|
||||
from .settings import TestSettings
|
||||
from .support import TestSupport
|
||||
|
||||
__all__ = [
|
||||
"TestAddressbook", "TestMain", "TestSettings", "TestSupport",
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
"""Common definitions for bitmessageqt tests"""
|
||||
|
||||
import Queue
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from six.moves import queue
|
||||
|
||||
import bitmessageqt
|
||||
import queues
|
||||
from tr import _translate
|
||||
from bitmessageqt import _translate, config, queues
|
||||
|
||||
|
||||
class TestBase(unittest.TestCase):
|
||||
"""Base class for bitmessageqt test case"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Provide the UI test cases with common settings"""
|
||||
cls.config = config
|
||||
|
||||
def setUp(self):
|
||||
self.app = (
|
||||
QtGui.QApplication.instance()
|
||||
|
@ -24,14 +28,21 @@ class TestBase(unittest.TestCase):
|
|||
self.window.appIndicatorInit(self.app)
|
||||
|
||||
def tearDown(self):
|
||||
"""Search for exceptions in closures called by timer and fail if any"""
|
||||
# self.app.deleteLater()
|
||||
concerning = []
|
||||
while True:
|
||||
try:
|
||||
thread, exc = queues.excQueue.get(block=False)
|
||||
except Queue.Empty:
|
||||
return
|
||||
except queue.Empty:
|
||||
break
|
||||
if thread == 'tests':
|
||||
self.fail('Exception in the main thread: %s' % exc)
|
||||
concerning.append(exc)
|
||||
if concerning:
|
||||
self.fail(
|
||||
'Exceptions found in the main thread:\n%s' % '\n'.join((
|
||||
str(e) for e in concerning
|
||||
)))
|
||||
|
||||
|
||||
class TestMain(unittest.TestCase):
|
||||
|
|
Reference in New Issue
Block a user