eric7/Project/PropertiesDialog.py

branch
eric7-maintenance
changeset 9111
4ac66b6c33a4
parent 8881
54e42bc2437a
child 9192
a763d57e23bc
--- a/eric7/Project/PropertiesDialog.py	Mon May 02 15:53:05 2022 +0200
+++ b/eric7/Project/PropertiesDialog.py	Wed Jun 01 13:48:49 2022 +0200
@@ -7,6 +7,7 @@
 Module implementing the project properties dialog.
 """
 
+import contextlib
 import os
 
 from PyQt6.QtCore import QDir, pyqtSlot
@@ -19,6 +20,8 @@
 
 from QScintilla.DocstringGenerator import getSupportedDocstringTypes
 
+from Testing.Interfaces import FrameworkNames
+
 import Utilities
 import Preferences
 import UI.PixmapCache
@@ -133,6 +136,10 @@
             cindex = self.docstringStyleComboBox.findData(
                 self.project.pdata["DOCSTRING"])
             self.docstringStyleComboBox.setCurrentIndex(cindex)
+            with contextlib.suppress(KeyError):
+                cindex = self.testingFrameworkComboBox.findData(
+                    self.project.pdata["TESTING_FRAMEWORK"])
+                self.testingFrameworkComboBox.setCurrentIndex(cindex)
         else:
             self.languageComboBox.setCurrentIndex(
                 self.languageComboBox.findText("Python3"))
@@ -149,29 +156,36 @@
             bool(self.dirPicker.text()) and
             self.dirPicker.text() not in self.__initPaths)
     
-    @pyqtSlot(int)
-    def on_languageComboBox_currentIndexChanged(self, index):
+    @pyqtSlot(str)
+    def on_languageComboBox_currentTextChanged(self, language):
         """
         Private slot handling the selection of a programming language.
         
-        @param index index of the current item
-        @type int
+        @param language text of the current item
+        @type str
         """
-        language = self.languageComboBox.itemText(index)
         curProjectType = self.getProjectType()
         
-        projectTypes = []
-        for projectTypeItem in self.project.getProjectTypes(language).items():
-            projectTypes.append((projectTypeItem[1], projectTypeItem[0]))
         self.projectTypeComboBox.clear()
-        for projectType in sorted(projectTypes):
+        for projectType in sorted(
+            self.project.getProjectTypes(language).items(),
+            key=lambda k: k[1]
+        ):
             self.projectTypeComboBox.addItem(
-                projectType[0], projectType[1])
+                projectType[1], projectType[0])
         
         index = self.projectTypeComboBox.findData(curProjectType)
         if index == -1:
             index = 0
         self.projectTypeComboBox.setCurrentIndex(index)
+        
+        curTestingFramework = self.testingFrameworkComboBox.currentText()
+        self.testingFrameworkComboBox.clear()
+        self.testingFrameworkComboBox.addItem(self.tr("None"), "")
+        with contextlib.suppress(KeyError):
+            for framework in sorted(FrameworkNames[language]):
+                self.testingFrameworkComboBox.addItem(framework, framework)
+        self.testingFrameworkComboBox.setCurrentText(curTestingFramework)
     
     @pyqtSlot(str)
     def on_dirPicker_textChanged(self, txt):
@@ -335,3 +349,7 @@
         self.project.pdata["DOCSTRING"] = (
             self.docstringStyleComboBox.currentData()
         )
+        
+        self.project.pdata["TESTING_FRAMEWORK"] = (
+            self.testingFrameworkComboBox.currentData()
+        )

eric ide

mercurial