eric6/PyUnit/UnittestDialog.py

branch
maintenance
changeset 8176
31965986ecd1
parent 8043
0acf98cd089a
parent 8149
3fefc0c430f2
child 8273
698ae46f40a4
diff -r e01ae92db699 -r 31965986ecd1 eric6/PyUnit/UnittestDialog.py
--- a/eric6/PyUnit/UnittestDialog.py	Sat Mar 06 10:00:52 2021 +0100
+++ b/eric6/PyUnit/UnittestDialog.py	Sun Mar 28 15:00:11 2021 +0200
@@ -43,10 +43,10 @@
     unittestFile = pyqtSignal(str, int, bool)
     unittestStopped = pyqtSignal()
     
-    TestCaseNameRole = Qt.UserRole
-    TestCaseFileRole = Qt.UserRole + 1
+    TestCaseNameRole = Qt.ItemDataRole.UserRole
+    TestCaseFileRole = Qt.ItemDataRole.UserRole + 1
     
-    ErrorsInfoRole = Qt.UserRole
+    ErrorsInfoRole = Qt.ItemDataRole.UserRole
     
     SkippedColorDarkTheme = QColor("#00aaff")
     FailedExpectedColorDarkTheme = QColor("#ccaaff")
@@ -77,31 +77,33 @@
         self.setupUi(self)
         
         self.testsuitePicker.setMode(E5PathPickerModes.OpenFileMode)
-        self.testsuitePicker.setInsertPolicy(QComboBox.InsertAtTop)
+        self.testsuitePicker.setInsertPolicy(
+            QComboBox.InsertPolicy.InsertAtTop)
         self.testsuitePicker.setSizeAdjustPolicy(
-            QComboBox.AdjustToMinimumContentsLength)
+            QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
         
         self.discoveryPicker.setMode(E5PathPickerModes.DirectoryMode)
-        self.discoveryPicker.setInsertPolicy(QComboBox.InsertAtTop)
+        self.discoveryPicker.setInsertPolicy(
+            QComboBox.InsertPolicy.InsertAtTop)
         self.discoveryPicker.setSizeAdjustPolicy(
-            QComboBox.AdjustToMinimumContentsLength)
+            QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
         
         self.discoverButton = self.buttonBox.addButton(
-            self.tr("Discover"), QDialogButtonBox.ActionRole)
+            self.tr("Discover"), QDialogButtonBox.ButtonRole.ActionRole)
         self.discoverButton.setToolTip(self.tr(
             "Discover tests"))
         self.discoverButton.setWhatsThis(self.tr(
             """<b>Discover</b>"""
             """<p>This button starts a discovery of available tests.</p>"""))
         self.startButton = self.buttonBox.addButton(
-            self.tr("Start"), QDialogButtonBox.ActionRole)
+            self.tr("Start"), QDialogButtonBox.ButtonRole.ActionRole)
         self.startButton.setToolTip(self.tr(
             "Start the selected testsuite"))
         self.startButton.setWhatsThis(self.tr(
             """<b>Start Test</b>"""
             """<p>This button starts the selected testsuite.</p>"""))
         self.startFailedButton = self.buttonBox.addButton(
-            self.tr("Rerun Failed"), QDialogButtonBox.ActionRole)
+            self.tr("Rerun Failed"), QDialogButtonBox.ButtonRole.ActionRole)
         self.startFailedButton.setToolTip(
             self.tr("Reruns failed tests of the selected testsuite"))
         self.startFailedButton.setWhatsThis(self.tr(
@@ -109,7 +111,7 @@
             """<p>This button reruns all failed tests of the selected"""
             """ testsuite.</p>"""))
         self.stopButton = self.buttonBox.addButton(
-            self.tr("Stop"), QDialogButtonBox.ActionRole)
+            self.tr("Stop"), QDialogButtonBox.ButtonRole.ActionRole)
         self.stopButton.setToolTip(self.tr("Stop the running unittest"))
         self.stopButton.setWhatsThis(self.tr(
             """<b>Stop Test</b>"""
@@ -124,7 +126,7 @@
         
         self.setWindowFlags(
             self.windowFlags() | Qt.WindowFlags(
-                Qt.WindowContextHelpButtonHint))
+                Qt.WindowType.WindowContextHelpButtonHint))
         self.setWindowIcon(UI.PixmapCache.getIcon("eric"))
         self.setWindowTitle(self.tr("Unittest"))
         if dbs:
@@ -194,7 +196,7 @@
         
         @param evt key press event to handle (QKeyEvent)
         """
-        if evt.key() == Qt.Key_Escape and self.__dbs:
+        if evt.key() == Qt.Key.Key_Escape and self.__dbs:
             self.close()
     
     def __populateVenvComboBox(self):
@@ -549,8 +551,9 @@
                         itm = QTreeWidgetItem(pitm,
                                               [testPath[index - 1]])
                         pitm.setExpanded(True)
-                    itm.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
-                    itm.setCheckState(0, Qt.Unchecked)
+                    itm.setFlags(Qt.ItemFlag.ItemIsUserCheckable |
+                                 Qt.ItemFlag.ItemIsEnabled)
+                    itm.setCheckState(0, Qt.CheckState.Unchecked)
                     itm.setData(0, UnittestDialog.TestCaseNameRole, modulePath)
                     if (
                         os.path.splitext(os.path.basename(filename))[0] ==
@@ -578,7 +581,7 @@
             # top level
             for index in range(self.discoveryList.topLevelItemCount()):
                 itm = self.discoveryList.topLevelItem(index)
-                if itm.checkState(0) == Qt.Checked:
+                if itm.checkState(0) == Qt.CheckState.Checked:
                     selectedTests.append(
                         itm.data(0, UnittestDialog.TestCaseNameRole))
                     # ignore children because they are included implicitly
@@ -590,7 +593,7 @@
             # parent item with children
             for index in range(parent.childCount()):
                 itm = parent.child(index)
-                if itm.checkState(0) == Qt.Checked:
+                if itm.checkState(0) == Qt.CheckState.Checked:
                     selectedTests.append(
                         itm.data(0, UnittestDialog.TestCaseNameRole))
                     # ignore children because they are included implicitly
@@ -937,7 +940,7 @@
                 text = re.sub(pattern, "", text)
             
             foundItems = self.testsListWidget.findItems(
-                text, Qt.MatchFlags(Qt.MatchExactly))
+                text, Qt.MatchFlags(Qt.MatchFlag.MatchExactly))
             if len(foundItems) > 0:
                 itm = foundItems[0]
                 self.testsListWidget.setCurrentItem(itm)
@@ -1156,10 +1159,11 @@
         self.dlg.traceback = ui.traceback
         
         ui.showButton = ui.buttonBox.addButton(
-            self.tr("Show Source"), QDialogButtonBox.ActionRole)
+            self.tr("Show Source"), QDialogButtonBox.ButtonRole.ActionRole)
         ui.showButton.clicked.connect(self.__showSource)
         
-        ui.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
+        ui.buttonBox.button(
+            QDialogButtonBox.StandardButton.Close).setDefault(True)
         
         self.dlg.setWindowTitle(text)
         ui.testLabel.setText(test)
@@ -1355,7 +1359,7 @@
         @param event reference to the event object (QEvent)
         @return flag indicating, whether the event was handled (boolean)
         """
-        if event.type() == QEvent.Close:
+        if event.type() == QEvent.Type.Close:
             QApplication.exit()
             return True
         

eric ide

mercurial