PyBitmessage-2021-04-27/src/bitmessageqt/tests/main.py

61 lines
1.6 KiB
Python
Raw Normal View History

"""Common definitions for bitmessageqt tests"""
2020-10-09 14:55:21 +00:00
import Queue
import sys
import unittest
from PyQt4 import QtCore, QtGui
import bitmessageqt
2020-10-09 14:55:21 +00:00
import queues
from tr import _translate
class TestBase(unittest.TestCase):
"""Base class for bitmessageqt test case"""
def setUp(self):
2020-10-09 14:55:21 +00:00
self.app = (
QtGui.QApplication.instance()
or bitmessageqt.BitmessageQtApplication(sys.argv))
self.window = self.app.activeWindow()
if not self.window:
2018-11-07 16:25:11 +00:00
self.window = bitmessageqt.MainWindow()
2020-10-09 14:55:21 +00:00
self.window.appIndicatorInit(self.app)
def tearDown(self):
2020-10-09 14:55:21 +00:00
# self.app.deleteLater()
while True:
try:
thread, exc = queues.excQueue.get(block=False)
except Queue.Empty:
return
if thread == 'tests':
self.fail('Exception in the main thread: %s' % exc)
class TestMain(unittest.TestCase):
"""Test case for main window - basic features"""
def test_translate(self):
"""Check the results of _translate() with various args"""
self.assertIsInstance(
_translate("MainWindow", "Test"),
QtCore.QString
)
2020-10-09 14:55:21 +00:00
class TestUISignaler(TestBase):
"""Test case for UISignalQueue"""
def test_updateStatusBar(self):
"""Check arguments order of updateStatusBar command"""
queues.UISignalQueue.put((
'updateStatusBar', (
_translate("test", "Testing updateStatusBar..."), 1)
))
QtCore.QTimer.singleShot(60, self.app.quit)
self.app.exec_()
# self.app.processEvents(QtCore.QEventLoop.AllEvents, 60)