Пример #1
0
    def __init__(self, *args):
        View.__init__(self, *args)

        # Recent files menu
        self._recentFiles = LastValues(self.NAME, self._CONFIG_SECTION_MENU,
                                       "recent", 5)
        self._actionClearMenu = self._elements["actionClearMenu"]
        self._menuRecentFiles = self._menuFile[1]
        self._actionClearMenu.triggered.connect(self._recentFiles.clear)
        self._actionClearMenu.triggered.connect(self._updateRecentFiles)

        # Widgets
        self._treeWidget = self._elements["treeWidgetInfo"]
        self._tabWidget = self._elements["tabWidgetResults"]
        self._tabWidget.setTabBar(ClosableTabBar())
        self._widgetConsole = self._elements["widgetConsole"]
        self._buttonShowConsole = self._elements["buttonShowConsole"]
        self._buttonHideConsole = self._elements["buttonHideConsole"]
        self._splitterConsole = self._elements["splitterConsole"]
        self._buttonSaveOutput = self._elements["buttonSaveOutput"]
        self._textEdit = self._elements["textEditConsole"]
        self._tabs = {}
        self._treeWidget.setColumnCount(2)
        self._treeWidget.header().resizeSection(2, 0)
        self._treeWidget.header().setHorizontalScrollMode(
            QtGui.QAbstractItemView.ScrollPerPixel)
        self._treeWidget.header().setResizeMode(
            1, QtGui.QHeaderView.ResizeToContents)
        self._treeWidget.header().setResizeMode(2, QtGui.QHeaderView.Fixed)
        self._treeWidget.header().setStretchLastSection(True)
        self._widgetConsole.setVisible(False)
        self._buttonHideConsole.setVisible(False)
        self._tabWidget.currentChanged[int].connect(self._displaySelected)
        self._tabWidget.tabCloseRequested.connect(self._closeTabOfIndex)
        self._buttonShowConsole.clicked.connect(self._showConsole)
        self._buttonHideConsole.clicked.connect(self._hideConsole)
        self._buttonSaveOutput.clicked.connect(self._saveOutput)

        # Actions
        self._elements["actionOpen"].triggered.connect(self._openDialog)
        self._elements["actionClose"].triggered.connect(self._closeCurrentTab)
        self._actionExpand = self._elements["actionExpand"]
        self._actionExpandAll = self._elements["actionExpandAll"]
        self._actionCollapse = self._elements["actionCollapse"]
        self._actionCollapseAll = self._elements["actionCollapseAll"]

        # Console channel
        self._hideConsole()
        consoleChannelHelper = ConsoleChannelHelper(textEdit=self._textEdit)
        channels.add(ConsoleChannel,
                     "_ui_console",
                     console=consoleChannelHelper)
        self._splitterConsole.handle(1).setEnabled(False)

        # Tab channel
        self._resultChannelHelper = ResultChannelHelper(self)
        channels.add(ResultChannel,
                     "_ui_result",
                     result=self._resultChannelHelper)
Пример #2
0
    def __init__(self, parent):
        View.__init__(self, parent)
        self._devices = TestDeviceList(self._elements["treeWidgetDevices"])

        self._actionStart = self._elements["actionStart"]
        self._actionStop = self._elements["actionStop"]
        self._actionPause = self._elements["actionPause"]
        self._actionResume = self._elements["actionResume"]

        self._actionStart.triggered.connect(self._startTests)
        self._actionStop.triggered.connect(self._stopTests)
        self._actionPause.triggered.connect(self._pauseTests)
        self._actionResume.triggered.connect(self._resumeTests)

        self._actionStart.setVisible(True)
        self._actionStop.setVisible(False)
        self._actionPause.setVisible(False)
        self._actionResume.setVisible(False)

        # Summary channel
        channels.add("SummaryChannel", "_ui_summary")

        # Progress channel
        pBar = QtGui.QProgressBar()
        pBar.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
        font = pBar.font()
        font.setBold(True)
        pBar.setFont(font)
        self._parent.getStatusBar().addPermanentWidget(pBar, 1)
        self._progress = ProgressChannelHelper(pBar)
        channels.add(ProgressChannel, "_ui_progress", progress=self._progress)
        self._progress.testStarted.connect(self._onTestStarted)
        self._progress.testStopped.connect(self._onTestStopped)
        self._progress.stopped.connect(self._onStopped)

        self._tests = Tests(self._elements["treeWidgetLocations"],
                            self._elements["treeWidgetTests"],
                            self._elements["treeWidgetModels"])

        self._elements["actionAdd"].triggered.connect(self._tests.addLocation)
        self._elements["actionRemove"].triggered.connect(
                                                     self._tests.removeLocation)
        self._elements["actionExpand"].triggered.connect(
                                                     self._tests.expandSelected)
        self._elements["actionExpandAll"].triggered.connect(
                                                          self._tests.expandAll)
        self._elements["actionCollapse"].triggered.connect(
                                                   self._tests.collapseSelected)
        self._elements["actionCollapseAll"].triggered.connect(
                                                        self._tests.collapseAll)
        self._elements["actionRefresh"].triggered.connect(self._tests.refresh)

        # Initialize private test variables
        self._suiteRuns = 0
        self._todoSuites = 0
        self._testResult = None
        self._testRunner = None
Пример #3
0
    def __init__(self, parent):
        View.__init__(self, parent)
        self._devices = TestDeviceList(self._elements["treeWidgetDevices"])

        self._actionStart = self._elements["actionStart"]
        self._actionStop = self._elements["actionStop"]
        self._actionPause = self._elements["actionPause"]
        self._actionResume = self._elements["actionResume"]

        self._actionStart.triggered.connect(self._startTests)
        self._actionStop.triggered.connect(self._stopTests)
        self._actionPause.triggered.connect(self._pauseTests)
        self._actionResume.triggered.connect(self._resumeTests)

        self._actionStart.setVisible(True)
        self._actionStop.setVisible(False)
        self._actionPause.setVisible(False)
        self._actionResume.setVisible(False)

        # Summary channel
        channels.add("SummaryChannel", "_ui_summary")

        # Progress channel
        pBar = QtGui.QProgressBar()
        pBar.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
        font = pBar.font()
        font.setBold(True)
        pBar.setFont(font)
        self._parent.getStatusBar().addPermanentWidget(pBar, 1)
        self._progress = ProgressChannelHelper(pBar)
        channels.add(ProgressChannel, "_ui_progress", progress=self._progress)
        self._progress.testStarted.connect(self._onTestStarted)
        self._progress.testStopped.connect(self._onTestStopped)
        self._progress.stopped.connect(self._onStopped)

        self._tests = Tests(self._elements["treeWidgetLocations"],
                            self._elements["treeWidgetTests"],
                            self._elements["treeWidgetModels"])

        self._elements["actionAdd"].triggered.connect(self._tests.addLocation)
        self._elements["actionRemove"].triggered.connect(
            self._tests.removeLocation)
        self._elements["actionExpand"].triggered.connect(
            self._tests.expandSelected)
        self._elements["actionExpandAll"].triggered.connect(
            self._tests.expandAll)
        self._elements["actionCollapse"].triggered.connect(
            self._tests.collapseSelected)
        self._elements["actionCollapseAll"].triggered.connect(
            self._tests.collapseAll)
        self._elements["actionRefresh"].triggered.connect(self._tests.refresh)

        # Initialize private test variables
        self._suiteRuns = 0
        self._todoSuites = 0
        self._testResult = None
        self._testRunner = None
Пример #4
0
    def __init__(self, *args):
        View.__init__(self, *args)

        # Recent files menu
        self._recentFiles = LastValues(self.NAME, self._CONFIG_SECTION_MENU,
                                       "recent", 5)
        self._actionClearMenu = self._elements["actionClearMenu"]
        self._menuRecentFiles = self._menuFile[1]
        self._actionClearMenu.triggered.connect(self._recentFiles.clear)
        self._actionClearMenu.triggered.connect(self._updateRecentFiles)

        # Widgets
        self._treeWidget = self._elements["treeWidgetInfo"]
        self._tabWidget = self._elements["tabWidgetResults"]
        self._tabWidget.setTabBar(ClosableTabBar())
        self._widgetConsole = self._elements["widgetConsole"]
        self._buttonShowConsole = self._elements["buttonShowConsole"]
        self._buttonHideConsole = self._elements["buttonHideConsole"]
        self._splitterConsole = self._elements["splitterConsole"]
        self._buttonSaveOutput = self._elements["buttonSaveOutput"]
        self._textEdit = self._elements["textEditConsole"]
        self._tabs = {}
        self._treeWidget.setColumnCount(2)
        self._treeWidget.header().resizeSection(2, 0)
        self._treeWidget.header().setHorizontalScrollMode(
            QtGui.QAbstractItemView.ScrollPerPixel)
        self._treeWidget.header().setResizeMode(1,
            QtGui.QHeaderView.ResizeToContents)
        self._treeWidget.header().setResizeMode(2, QtGui.QHeaderView.Fixed)
        self._treeWidget.header().setStretchLastSection(True)
        self._widgetConsole.setVisible(False)
        self._buttonHideConsole.setVisible(False)
        self._tabWidget.currentChanged[int].connect(self._displaySelected)
        self._tabWidget.tabCloseRequested.connect(self._closeTabOfIndex)
        self._buttonShowConsole.clicked.connect(self._showConsole)
        self._buttonHideConsole.clicked.connect(self._hideConsole)
        self._buttonSaveOutput.clicked.connect(self._saveOutput)

        # Actions
        self._elements["actionOpen"].triggered.connect(self._openDialog)
        self._elements["actionClose"].triggered.connect(self._closeCurrentTab)
        self._actionExpand = self._elements["actionExpand"]
        self._actionExpandAll = self._elements["actionExpandAll"]
        self._actionCollapse = self._elements["actionCollapse"]
        self._actionCollapseAll = self._elements["actionCollapseAll"]

        # Console channel
        self._hideConsole()
        consoleChannelHelper = ConsoleChannelHelper(textEdit=self._textEdit)
        channels.add(ConsoleChannel, "_ui_console",
                     console=consoleChannelHelper)
        self._splitterConsole.handle(1).setEnabled(False)

        # Tab channel
        self._resultChannelHelper = ResultChannelHelper(self)
        channels.add(ResultChannel, "_ui_result",
                     result=self._resultChannelHelper)
Пример #5
0
 def testGetPredefined(self):
     channels.add(TestClass1, "_testchl1")
     channels.add("TestClass01", "_testchl2", arg2=0)
     channelList = channels.get()
     for channel in channelList:
         if channel.name == "_testchl1":
             break
     self.failUnlessEqual(channel.name, "_testchl1")
     self.failUnless(isinstance(channel, TestClass1))
     for channel in channelList:
         if channel.name == "_testchl2":
             break
     self.failUnlessEqual(channel.name, "_testchl2")
     self.failUnless(isinstance(channel, TestClass01))
Пример #6
0
 def testAdd2(self):
     name1 = "test1"
     name2 = "test2"
     params = {'a':1}
     channels.add(TestClass1, name1, **params)
     self.assertTrue(name1 in channels._cache)
     self.assertEqual(TestClass1, channels._cache[name1][0])
     self.assertTrue('a' in channels._cache[name1][1])
     self.assertEqual(1, channels._cache[name1][1]['a'])
     length = len(channels._cache)
     self.exceptionMessage = "Channel with such a name already exists:"
     self.assertRaises(ValueError, channels.add, TestClass1, name1)
     channels.add(TestClass1, name2)
     self.assertEqual(len(channels._cache), length+1)
Пример #7
0
 def testGetPredefined(self):
     channels.add(TestClass1, "_testchl1")
     channels.add("TestClass01", "_testchl2", arg2=0)
     channelList = channels.get()
     for channel in channelList:
         if channel.name == "_testchl1":
             break
     self.failUnlessEqual(channel.name, "_testchl1")
     self.failUnless(isinstance(channel, TestClass1))
     for channel in channelList:
         if channel.name == "_testchl2":
             break
     self.failUnlessEqual(channel.name, "_testchl2")
     self.failUnless(isinstance(channel, TestClass01))
Пример #8
0
 def testAdd2(self):
     name1 = "test1"
     name2 = "test2"
     params = {'a': 1}
     channels.add(TestClass1, name1, **params)
     self.assertTrue(name1 in channels._cache)
     self.assertEqual(TestClass1, channels._cache[name1][0])
     self.assertTrue('a' in channels._cache[name1][1])
     self.assertEqual(1, channels._cache[name1][1]['a'])
     length = len(channels._cache)
     self.exceptionMessage = "Channel with such a name already exists:"
     self.assertRaises(ValueError, channels.add, TestClass1, name1)
     channels.add(TestClass1, name2)
     self.assertEqual(len(channels._cache), length + 1)
Пример #9
0
 def testAdd3(self):
     name1 = "test1"
     name2 = "test2"
     self.exceptionMessage = "Invalid channel class name:"
     self.assertRaises(TypeError, channels.add, "TestClass1", "test1")
     channels.register(TestClass1)
     className1 = TestClass1.__name__
     channels.add(className1, name1)
     self.assertTrue(name1 in channels._cache)
     self.assertEqual(TestClass1, channels._cache[name1][0])
     length = len(channels._cache)
     self.exceptionMessage = "Channel with such a name already exists:"
     self.assertRaises(ValueError, channels.add, className1, name1)
     channels.add(TestClass1, name2)
     self.assertEqual(len(channels._cache), length+1)
Пример #10
0
 def testAdd3(self):
     name1 = "test1"
     name2 = "test2"
     self.exceptionMessage = "Invalid channel class name:"
     self.assertRaises(TypeError, channels.add, "TestClass1", "test1")
     channels.register(TestClass1)
     className1 = TestClass1.__name__
     channels.add(className1, name1)
     self.assertTrue(name1 in channels._cache)
     self.assertEqual(TestClass1, channels._cache[name1][0])
     length = len(channels._cache)
     self.exceptionMessage = "Channel with such a name already exists:"
     self.assertRaises(ValueError, channels.add, className1, name1)
     channels.add(TestClass1, name2)
     self.assertEqual(len(channels._cache), length + 1)
Пример #11
0
def runTestCases(tests, locations, devices):
    '''
    A function responsible for running the given test cases.
    '''
    log.debug("Run test cases from '%s' locations using '%s' devices: %s"
               % (", ".join(locations), ", ".join([str(d) for d in devices]),
                  ", ".join(tests)))
    loader = TestLoader()
    amountToRun = 0
    for path in locations:
        location.add(path)
    if not isinstance(tests, (list, tuple)):
        tests = [tests]
    suites, errors = loader.loadFromNames(*tests)

    ncases = 0
    for test in suites:
        ncases += test.count()
    print (" LOADED %d TEST CASES " % ncases).center(80, '-') + '\n'

    if len(errors) > 0:
        print "There were errors during loading test cases:"
        for error in errors:
            print "%s\n%s" % (error.name, error.traceback)
            printSeparator()
        print

    if not ncases:
        #Nothing to do
        exitWithStatus(status=0)

    log.info("Start running tests: %s" % suites)
    channels.add("SummaryChannel", SUMMARY_CHANNEL)
    result = testresult.TestResult()
    runner = TestRunner(devices, suites, result)

    for device in devices:
        device.connect()
    try:
        runner.start()
        runner.join()
    except KeyboardInterrupt:
        runner.stop()
    finally:
        for device in devices:
            if device.isConnected():
                device.disconnect()
    return result