eric6/PyUnit/UnittestDialog.py

changeset 8328
e22ce9001905
parent 8240
93b8a353c4bf
child 8380
73ef1edca602
equal deleted inserted replaced
8326:0a99aecb5d91 8328:e22ce9001905
578 @rtype list of str 578 @rtype list of str
579 """ 579 """
580 selectedTests = [] 580 selectedTests = []
581 if parent is None: 581 if parent is None:
582 # top level 582 # top level
583 for index in range(self.discoveryList.topLevelItemCount()): 583 itemsList = [
584 itm = self.discoveryList.topLevelItem(index) 584 self.discoveryList.topLevelItem(index)
585 if itm.checkState(0) == Qt.CheckState.Checked: 585 for index in range(self.discoveryList.topLevelItemCount())
586 selectedTests.append( 586 ]
587 itm.data(0, UnittestDialog.TestCaseNameRole))
588 # ignore children because they are included implicitly
589 elif itm.childCount():
590 # recursively check children
591 selectedTests.extend(self.__selectedTestCases(itm))
592
593 else: 587 else:
594 # parent item with children 588 itemsList = [
595 for index in range(parent.childCount()): 589 parent.child(index)
596 itm = parent.child(index) 590 for index in range(parent.childCount())
597 if itm.checkState(0) == Qt.CheckState.Checked: 591 ]
598 selectedTests.append( 592
599 itm.data(0, UnittestDialog.TestCaseNameRole)) 593 for itm in itemsList:
600 # ignore children because they are included implicitly 594 if (itm.checkState(0) == Qt.CheckState.Checked and
601 elif itm.childCount(): 595 itm.childCount() == 0
602 # recursively check children 596 ):
603 selectedTests.extend(self.__selectedTestCases(itm)) 597 selectedTests.append(
598 itm.data(0, UnittestDialog.TestCaseNameRole))
599 if itm.childCount():
600 # recursively check children
601 selectedTests.extend(self.__selectedTestCases(itm))
604 602
605 return selectedTests 603 return selectedTests
606 604
607 def __UTDiscovered(self, testCases, exc_type, exc_value): 605 def __UTDiscovered(self, testCases, exc_type, exc_value):
608 """ 606 """
879 cover = None 877 cover = None
880 878
881 self.testResult = QtTestResult( 879 self.testResult = QtTestResult(
882 self, self.failfastCheckBox.isChecked()) 880 self, self.failfastCheckBox.isChecked())
883 self.totalTests = test.countTestCases() 881 self.totalTests = test.countTestCases()
884 self.__failedTests = [] 882 if self.totalTests == 0:
885 self.__setRunningMode() 883 E5MessageBox.warning(
886 if cover: 884 self,
887 cover.start() 885 self.tr("Unittest"),
888 test.run(self.testResult) 886 self.tr("""No unittest were found. Aborting..."""))
889 if cover: 887 else:
890 cover.stop() 888 self.__failedTests = []
891 cover.save() 889 self.__setRunningMode()
892 self.__setStoppedMode() 890 if cover:
893 sys.path = self.savedSysPath 891 cover.start()
892 test.run(self.testResult)
893 if cover:
894 cover.stop()
895 cover.save()
896 self.__setStoppedMode()
897 sys.path = self.savedSysPath
894 898
895 def __UTPrepared(self, nrTests, exc_type, exc_value): 899 def __UTPrepared(self, nrTests, exc_type, exc_value):
896 """ 900 """
897 Private slot to handle the utPrepared signal. 901 Private slot to handle the utPrepared signal.
898 902

eric ide

mercurial