UnittestDialog: fixed an issue running tests for a project and removed the (obsolete) 'local' option.

Fri, 22 Mar 2019 19:11:11 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 22 Mar 2019 19:11:11 +0100
changeset 6892
c147620313c5
parent 6891
93f82da09f22
child 6893
d29a7b8fab0f

UnittestDialog: fixed an issue running tests for a project and removed the (obsolete) 'local' option.

DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
Debugger/DebugServer.py file | annotate | diff | comparison | revisions
Debugger/DebuggerInterfaceNone.py file | annotate | diff | comparison | revisions
Debugger/DebuggerInterfacePython.py file | annotate | diff | comparison | revisions
PyUnit/UnittestDialog.py file | annotate | diff | comparison | revisions
PyUnit/UnittestDialog.ui file | annotate | diff | comparison | revisions
changelog file | annotate | diff | comparison | revisions
--- a/DebugClients/Python/DebugClientBase.py	Thu Mar 21 19:27:42 2019 +0100
+++ b/DebugClients/Python/DebugClientBase.py	Fri Mar 22 19:11:11 2019 +0100
@@ -802,6 +802,8 @@
             self.__completionList(params["text"])
         
         elif method == "RequestUTPrepare":
+            if params["syspath"]:
+                sys.path = params["syspath"] + sys.path
             sys.path.insert(
                 0, os.path.dirname(os.path.abspath(params["filename"])))
             os.chdir(sys.path[0])
--- a/Debugger/DebugServer.py	Thu Mar 21 19:27:42 2019 +0100
+++ b/Debugger/DebugServer.py	Fri Mar 22 19:11:11 2019 +0100
@@ -1313,7 +1313,8 @@
         self.debuggerInterface.remoteCompletion(text)
 
     def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase,
-                        clientType="", forProject=False, venvName=""):
+                        clientType="", forProject=False, venvName="",
+                        syspath=None):
         """
         Public method to prepare a new unittest run.
         
@@ -1338,8 +1339,11 @@
         @type bool
         @param venvName name of a virtual environment
         @type str
+        @param syspath list of directories to be added to sys.path on the
+            remote side
+        @type list of str
         """
-        if clientType not in self.getSupportedLanguages():
+        if clientType and clientType not in self.getSupportedLanguages():
             # a not supported client language was requested
             E5MessageBox.critical(
                 None,
@@ -1362,7 +1366,7 @@
         self.startClient(False, forProject=forProject, venvName=venvName)
         
         self.debuggerInterface.remoteUTPrepare(
-            fn, tn, tfn, failed, cov, covname, coverase)
+            fn, tn, tfn, failed, cov, covname, coverase, syspath)
         self.debugging = False
         self.running = True
         
--- a/Debugger/DebuggerInterfaceNone.py	Thu Mar 21 19:27:42 2019 +0100
+++ b/Debugger/DebuggerInterfaceNone.py	Fri Mar 22 19:11:11 2019 +0100
@@ -408,21 +408,29 @@
         """
         return
         
-    def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase):
+    def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase,
+                        syspath):
         """
         Public method to prepare a new unittest run.
         
-        @param fn the filename to load (string)
-        @param tn the testname to load (string)
-        @param tfn the test function name to load tests from (string)
+        @param fn name of file to load
+        @type str
+        @param tn name of test to load
+        @type str
+        @param tfn test function name to load tests from
+        @type str
         @param failed list of failed test, if only failed test should be run
-            (list of strings)
+        @type list of str
         @param cov flag indicating collection of coverage data is requested
-            (boolean)
-        @param covname filename to be used to assemble the coverage caches
-            filename (string)
+        @type bool
+        @param covname name of file to be used to assemble the coverage caches
+            filename
+        @type str
         @param coverase flag indicating erasure of coverage data is requested
-            (boolean)
+        @type bool
+        @param syspath list of directories to be added to sys.path on the
+            remote side
+        @type list of str
         """
         return
         
--- a/Debugger/DebuggerInterfacePython.py	Thu Mar 21 19:27:42 2019 +0100
+++ b/Debugger/DebuggerInterfacePython.py	Fri Mar 22 19:11:11 2019 +0100
@@ -927,21 +927,29 @@
             "text": text,
         })
     
-    def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase):
+    def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase,
+                        syspath):
         """
         Public method to prepare a new unittest run.
         
-        @param fn the filename to load (string)
-        @param tn the testname to load (string)
-        @param tfn the test function name to load tests from (string)
+        @param fn name of file to load
+        @type str
+        @param tn name of test to load
+        @type str
+        @param tfn test function name to load tests from
+        @type str
         @param failed list of failed test, if only failed test should be run
-            (list of strings)
+        @type list of str
         @param cov flag indicating collection of coverage data is requested
-            (boolean)
-        @param covname filename to be used to assemble the coverage caches
-            filename (string)
+        @type bool
+        @param covname name of file to be used to assemble the coverage caches
+            filename
+        @type str
         @param coverase flag indicating erasure of coverage data is requested
-            (boolean)
+        @type bool
+        @param syspath list of directories to be added to sys.path on the
+            remote side
+        @type list of str
         """
         self.__scriptName = os.path.abspath(fn)
         
@@ -954,6 +962,7 @@
             "coverage": cov,
             "coveragefile": covname,
             "coverageerase": coverase,
+            "syspath": [] if syspath is None else syspath,
         })
     
     def remoteUTRun(self):
--- a/PyUnit/UnittestDialog.py	Thu Mar 21 19:27:42 2019 +0100
+++ b/PyUnit/UnittestDialog.py	Fri Mar 22 19:11:11 2019 +0100
@@ -105,8 +105,6 @@
         self.setWindowTitle(self.tr("Unittest"))
         if dbs:
             self.ui = ui
-        else:
-            self.localCheckBox.hide()
         self.__setProgressColor("green")
         self.progressLed.setDarkFactor(150)
         self.progressLed.off()
@@ -236,31 +234,6 @@
         """
         self.insertProg(suite)
         
-    @pyqtSlot(str)
-    def on_testsuitePicker_editTextChanged(self, txt):
-        """
-        Private slot to handle changes of the test file name.
-        
-        @param txt name of the test file (string)
-        """
-        fileTypes = {
-            "Python2": ("Python", "Python2"),
-            "Python3": ("Python3", )
-        }
-        if self.__dbs:
-            ver = sys.version_info[0]
-            variant = "Python{0}".format(ver)
-            exts = self.__dbs.getExtensions(variant)
-            flags = Utilities.extractFlagsFromFile(txt)
-            if not txt.endswith(exts) or \
-               ("FileType" in flags and
-                    flags["FileType"] not in fileTypes[variant]):
-                self.localCheckBox.setChecked(False)
-                self.localCheckBox.setEnabled(False)
-                return
-        
-        self.localCheckBox.setEnabled(bool(self.__dbs))
-        
     def on_buttonBox_clicked(self, button):
         """
         Private slot called by a button of the button box clicked.
@@ -306,15 +279,17 @@
         # build the module name from the filename without extension
         self.testName = os.path.splitext(os.path.basename(prog))[0]
         
-        if self.__dbs and not self.localCheckBox.isChecked():
+        if self.__dbs:
             # we are cooperating with the eric6 IDE
             project = e5App().getObject("Project")
             if self.__forProject and project.isOpen() and \
                project.isProjectSource(prog):
-                mainScript = project.getMainScript(True)
+                mainScript = os.path.abspath(project.getMainScript(True))
                 clientType = project.getProjectLanguage()
+                sysPath = [os.path.dirname(mainScript)]
             else:
                 mainScript = os.path.abspath(prog)
+                sysPath = []
                 flags = Utilities.extractFlagsFromFile(mainScript)
                 if mainScript.endswith(
                     tuple(Preferences.getPython("PythonExtensions"))) or \
@@ -334,9 +309,9 @@
                 self.coverageCheckBox.isChecked(), mainScript,
                 self.coverageEraseCheckBox.isChecked(), clientType=clientType,
                 forProject=self.__forProject,
-                venvName=self.venvComboBox.currentText())
+                venvName=self.venvComboBox.currentText(), syspath=sysPath)
         else:
-            # we are running as an application or in local mode
+            # we are running as an application
             sys.path = [os.path.dirname(os.path.abspath(prog))] + \
                 self.savedSysPath
             
@@ -440,7 +415,7 @@
         """
         Private slot to stop the test.
         """
-        if self.__dbs and not self.localCheckBox.isChecked():
+        if self.__dbs:
             self.__dbs.remoteUTStop()
         elif self.testResult:
             self.testResult.stop()
@@ -613,7 +588,7 @@
         if doc:
             self.testsListWidget.insertItem(0, "    {0}".format(doc))
         self.testsListWidget.insertItem(0, test)
-        if self.__dbs is None or self.localCheckBox.isChecked():
+        if self.__dbs is None:
             QApplication.processEvents()
         
     def testFinished(self):
@@ -736,20 +711,6 @@
             except Exception:
                 # ignore all exceptions
                 pass
-    
-    @pyqtSlot(str)
-    def on_venvComboBox_currentTextChanged(self, venvName):
-        """
-        Private slot to handle the selection of a virtual environment.
-        
-        @param venvName name of the selected virtual environment
-        @type str
-        """
-        if venvName:
-            self.localCheckBox.setChecked(False)
-            self.localCheckBox.setEnabled(False)
-        else:
-            self.localCheckBox.setEnabled(True)
 
 
 class QtTestResult(unittest.TestResult):
--- a/PyUnit/UnittestDialog.ui	Thu Mar 21 19:27:42 2019 +0100
+++ b/PyUnit/UnittestDialog.ui	Fri Mar 22 19:11:11 2019 +0100
@@ -118,16 +118,6 @@
       <item>
        <layout class="QHBoxLayout" name="horizontalLayout_4">
         <item>
-         <widget class="QCheckBox" name="localCheckBox">
-          <property name="toolTip">
-           <string>Select whether you want to run the test locally</string>
-          </property>
-          <property name="text">
-           <string>Run &amp;local</string>
-          </property>
-         </widget>
-        </item>
-        <item>
          <widget class="QCheckBox" name="coverageCheckBox">
           <property name="toolTip">
            <string>Select whether coverage data should be collected</string>
@@ -452,7 +442,6 @@
   <tabstop>testsuitePicker</tabstop>
   <tabstop>testComboBox</tabstop>
   <tabstop>venvComboBox</tabstop>
-  <tabstop>localCheckBox</tabstop>
   <tabstop>coverageCheckBox</tabstop>
   <tabstop>coverageEraseCheckBox</tabstop>
   <tabstop>testsListWidget</tabstop>
--- a/changelog	Thu Mar 21 19:27:42 2019 +0100
+++ b/changelog	Fri Mar 22 19:11:11 2019 +0100
@@ -22,6 +22,7 @@
 - Unit Test
   -- added the capability to select the virtual environment for the unittest
      run
+  -- removed the 'local' selection because it is obsolete
 - Web Browser (NG)
   -- added these search engines to the default list:
      --- MetaGer

eric ide

mercurial