コード例 #1
0
ファイル: tests.py プロジェクト: tadek-project/tadek-ui
    def getCheckedTests(self):
        '''
        Loads checked tests cases and returns them in a list on success
        or None on failure.
        '''
        def findCheckedNames(tests, item):
            if item.checkState(0) == QtCore.Qt.Checked:
                tests.append(item.testName)
                return
            elif item.checkState(0) == QtCore.Qt.PartiallyChecked:
                for i in xrange(item.childCount()):
                    findCheckedNames(tests, item.child(i))

        names = []
        for i in xrange(self._testsTree.topLevelItemCount()):
            findCheckedNames(names, self._testsTree.topLevelItem(i))
        if not names:
            runWarning("Select some test cases first")
            return names
        tests, errors = self._loader.loadFromNames(*names)
        if errors:
            if self._loaded:
                dialog = LoadingErrorDialog(
                    "Errors occurred while loading "
                    "test cases", errors)
                dialog.run()
                return []

        return tests
コード例 #2
0
ファイル: tests.py プロジェクト: mlyko/tadek-ui
    def getCheckedTests(self):
        '''
        Loads checked tests cases and returns them in a list on success
        or None on failure.
        '''
        def findCheckedNames(tests, item):
            if item.checkState(0) == QtCore.Qt.Checked:
                tests.append(item.testName)
                return
            elif item.checkState(0) == QtCore.Qt.PartiallyChecked:
                for i in xrange(item.childCount()):
                    findCheckedNames(tests, item.child(i))
        
        names = []
        for i in xrange(self._testsTree.topLevelItemCount()):
            findCheckedNames(names, self._testsTree.topLevelItem(i))
        if not names:
            runWarning("Select some test cases first")
            return names
        tests, errors = self._loader.loadFromNames(*names)
        if errors:
            if self._loaded:
                dialog = LoadingErrorDialog("Errors occurred while loading "
                                            "test cases", errors)
                dialog.run()
                return []

        return tests
コード例 #3
0
ファイル: tests.py プロジェクト: mlyko/tadek-ui
 def _updateLocations(self, item, column):
     '''
     Enables or disables a location and refreshes the tests tree.
     '''
     if item.checkState(0) == QtCore.Qt.Checked:
         errors = location.enable(item.text(0))
         if errors:
             if self._loaded:
                 dialog = LoadingErrorDialog("Errors occurred while enabling"
                                             " a location", errors)
                 dialog.run()
             item.setCheckState(0, QtCore.Qt.Unchecked)
             return
     else:
         location.disable(item.text(0))
     self.refresh()
コード例 #4
0
ファイル: tests.py プロジェクト: tadek-project/tadek-ui
 def _updateLocations(self, item, column):
     '''
     Enables or disables a location and refreshes the tests tree.
     '''
     if item.checkState(0) == QtCore.Qt.Checked:
         errors = location.enable(item.text(0))
         if errors:
             if self._loaded:
                 dialog = LoadingErrorDialog(
                     "Errors occurred while enabling"
                     " a location", errors)
                 dialog.run()
             item.setCheckState(0, QtCore.Qt.Unchecked)
             return
     else:
         location.disable(item.text(0))
     self.refresh()
コード例 #5
0
ファイル: tests.py プロジェクト: tadek-project/tadek-ui
    def refresh(self):
        '''
        Clears and fills the tests tree and the models tree with contents from
        currently enabled locations.
        '''
        def makeItem(parent):
            item = TestItem(parent)
            item.setFlags(QtCore.Qt.ItemIsEnabled
                          | QtCore.Qt.ItemIsUserCheckable
                          | QtCore.Qt.ItemIsSelectable)
            item.setCheckState(0, QtCore.Qt.Unchecked)
            return item

        def buildSuite(name, suite, parent):
            item = makeItem(parent)
            item.setText(
                0, name if name is not None else suite.__class__.__name__)
            item.testName = ".".join((item.parent().testName, item.text(0)))
            if isinstance(suite, TestSuite):
                item.setIcon(0, self._ICONS["suite"])
                for name, childSuite in suite:
                    buildSuite(name, childSuite, item)
            elif isinstance(suite, TestCase):
                item.setIcon(0, self._ICONS["case"])
            else:
                raise TypeError()

        def buildTree(tree, parent):
            for key in sorted(tree):
                value = tree[key]
                if key is None and isinstance(value, list):
                    if not value and len(tree) == 1:
                        if parent.parent() is not None:
                            parent.parent().removeChild(parent)
                        else:
                            self._testsTree.takeTopLevelItem(
                                self._testsTree.indexOfTopLevelItem(parent))
                        continue
                    suite = None
                    for suite in value:
                        buildSuite(None, suite, parent)
                    if value:
                        r = suite.result()
                        if os.path.split(r.path)[1] != r.id.split(".")[-2]:
                            parent.setIcon(0, self._ICONS["module"])
                elif isinstance(value, dict):
                    item = makeItem(parent)
                    item.setText(0, key)
                    item.setIcon(0, self._ICONS["directory"])
                    item.testName = (".".join(
                        (item.parent().testName,
                         key)) if item.parent() is not None else key)
                    buildTree(value, item)

        self._testsTree.clear()
        tree, errors = self._loader.loadTree()
        if errors:
            if self._loaded:
                dialog = LoadingErrorDialog(
                    "Errors occurred while loading "
                    "test cases", errors)
                dialog.run()
        buildTree(tree, self._testsTree)
        self._testsTree.resizeColumnToContents(0)
        if self._expandOnRefresh.getBool():
            self.expandAll()
        self._updateModels()
コード例 #6
0
ファイル: tests.py プロジェクト: mlyko/tadek-ui
    def refresh(self):
        '''
        Clears and fills the tests tree and the models tree with contents from
        currently enabled locations.
        '''
        def makeItem(parent):
            item = TestItem(parent)
            item.setFlags(QtCore.Qt.ItemIsEnabled |
                          QtCore.Qt.ItemIsUserCheckable |
                          QtCore.Qt.ItemIsSelectable)
            item.setCheckState(0, QtCore.Qt.Unchecked)
            return item

        def buildSuite(name, suite, parent):
            item = makeItem(parent)
            item.setText(0,
                         name if name is not None else suite.__class__.__name__)
            item.testName = ".".join((item.parent().testName, item.text(0)))
            if isinstance(suite, TestSuite):
                item.setIcon(0, self._ICONS["suite"])
                for name, childSuite in suite:
                    buildSuite(name, childSuite, item)
            elif isinstance(suite, TestCase):
                item.setIcon(0, self._ICONS["case"])
            else:
                raise TypeError()

        def buildTree(tree, parent):
            for key in sorted(tree):
                value = tree[key]
                if key is None and isinstance(value, list):
                    if not value and len(tree) == 1:
                        if parent.parent() is not None:
                            parent.parent().removeChild(parent)
                        else:
                            self._testsTree.takeTopLevelItem(
                                self._testsTree.indexOfTopLevelItem(parent))
                        continue
                    suite = None
                    for suite in value:
                        buildSuite(None, suite, parent)
                    if value:
                        r = suite.result()
                        if os.path.split(r.path)[1] != r.id.split(".")[-2]:
                            parent.setIcon(0, self._ICONS["module"])
                elif isinstance(value, dict):
                    item = makeItem(parent)
                    item.setText(0, key)
                    item.setIcon(0, self._ICONS["directory"])
                    item.testName = (".".join((item.parent().testName, key))
                                      if item.parent() is not None else key)
                    buildTree(value, item)

        self._testsTree.clear()
        tree, errors = self._loader.loadTree()
        if errors:
            if self._loaded:
                dialog = LoadingErrorDialog("Errors occurred while loading "
                                            "test cases", errors)
                dialog.run()
        buildTree(tree, self._testsTree)
        self._testsTree.resizeColumnToContents(0)
        if self._expandOnRefresh.getBool():
            self.expandAll()
        self._updateModels()