Fri, 22 Mar 2019 19:31:56 +0100
UnittestDialog: changed code to set the default directory of the test file picker file selection dialog to the project directory when in project mode.
PyUnit/UnittestDialog.py | file | annotate | diff | comparison | revisions |
--- a/PyUnit/UnittestDialog.py Fri Mar 22 19:11:11 2019 +0100 +++ b/PyUnit/UnittestDialog.py Fri Mar 22 19:31:56 2019 +0100 @@ -189,7 +189,7 @@ self.fileHistory.insert(0, prog) self.testsuitePicker.clear() self.testsuitePicker.addItems(self.fileHistory) - + def insertTestName(self, testName): """ Public slot to insert a test name into the testComboBox object. @@ -204,7 +204,7 @@ self.testNameHistory.insert(0, testName) self.testComboBox.clear() self.testComboBox.addItems(self.testNameHistory) - + @pyqtSlot() def on_testsuitePicker_aboutToShowPathPickerDialog(self): """ @@ -224,6 +224,14 @@ fileFilter = self.tr("Python Files (*.py);;All Files (*)") self.testsuitePicker.setFilters(fileFilter) + defaultDirectory = Preferences.getMultiProject("Workspace") + if not defaultDirectory: + defaultDirectory = os.path.expanduser("~") + if self.__dbs: + project = e5App().getObject("Project") + if self.__forProject and project.isOpen(): + defaultDirectory = project.getProjectPath() + @pyqtSlot(str) def on_testsuitePicker_pathSelected(self, suite): """ @@ -233,7 +241,7 @@ @type str """ self.insertProg(suite) - + def on_buttonBox_clicked(self, button): """ Private slot called by a button of the button box clicked. @@ -246,7 +254,7 @@ self.on_stopButton_clicked() elif button == self.startFailedButton: self.on_startButton_clicked(failedOnly=True) - + @pyqtSlot() def on_startButton_clicked(self, failedOnly=False): """ @@ -385,7 +393,7 @@ cover.save() self.__setStoppedMode() sys.path = self.savedSysPath - + def __UTPrepared(self, nrTests, exc_type, exc_value): """ Private slot to handle the utPrepared signal. @@ -409,7 +417,7 @@ self.totalTests = nrTests self.__setRunningMode() self.__dbs.remoteUTRun() - + @pyqtSlot() def on_stopButton_clicked(self): """ @@ -419,7 +427,7 @@ self.__dbs.remoteUTStop() elif self.testResult: self.testResult.stop() - + def on_errorsListWidget_currentTextChanged(self, text): """ Private slot to handle the highlighted signal. @@ -436,7 +444,7 @@ itm = foundItems[0] self.testsListWidget.setCurrentItem(itm) self.testsListWidget.scrollToItem(itm) - + def __setRunningMode(self): """ Private method to set the GUI in running mode. @@ -451,7 +459,7 @@ self.expectedFailureCount = 0 self.unexpectedSuccessCount = 0 self.remainingCount = self.totalTests - + # reset the GUI self.progressCounterRunCount.setText(str(self.runCount)) self.progressCounterRemCount.setText(str(self.remainingCount)) @@ -475,7 +483,7 @@ QApplication.processEvents() self.startTime = time.time() - + def __setStoppedMode(self): """ Private method to set the GUI in stopped mode. @@ -504,7 +512,7 @@ self.progressLed.off() self.unittestStopped.emit() - + def testFailed(self, test, exc, testId): """ Public method called if a test fails. @@ -519,7 +527,7 @@ itm.setData(Qt.UserRole, (test, exc)) self.errorsListWidget.insertItem(0, itm) self.__failedTests.append(testId) - + def testErrored(self, test, exc, testId): """ Public method called if a test errors. @@ -534,7 +542,7 @@ itm.setData(Qt.UserRole, (test, exc)) self.errorsListWidget.insertItem(0, itm) self.__failedTests.append(testId) - + def testSkipped(self, test, reason, testId): """ Public method called if a test was skipped. @@ -548,7 +556,7 @@ itm = QListWidgetItem(self.tr(" Skipped: {0}").format(reason)) itm.setForeground(Qt.blue) self.testsListWidget.insertItem(1, itm) - + def testFailedExpected(self, test, exc, testId): """ Public method called if a test fails expectedly. @@ -563,7 +571,7 @@ itm = QListWidgetItem(self.tr(" Expected Failure")) itm.setForeground(Qt.blue) self.testsListWidget.insertItem(1, itm) - + def testSucceededUnexpected(self, test, testId): """ Public method called if a test succeeds unexpectedly. @@ -577,7 +585,7 @@ itm = QListWidgetItem(self.tr(" Unexpected Success")) itm.setForeground(Qt.red) self.testsListWidget.insertItem(1, itm) - + def testStarted(self, test, doc): """ Public method called if a test is about to be run. @@ -590,7 +598,7 @@ self.testsListWidget.insertItem(0, test) if self.__dbs is None: QApplication.processEvents() - + def testFinished(self): """ Public method called if a test has finished. @@ -609,7 +617,7 @@ elif self.failCount: self.__setProgressColor("orange") self.progressProgressBar.setValue(self.runCount) - + def on_errorsListWidget_itemDoubleClicked(self, lbitem): """ Private slot called by doubleclicking an errorlist entry. @@ -624,10 +632,10 @@ self.errListIndex = self.errorsListWidget.row(lbitem) text = lbitem.text() self.on_errorsListWidget_currentTextChanged(text) - + # get the error info test, tracebackText = lbitem.data(Qt.UserRole) - + # now build the dialog from .Ui_UnittestStacktraceDialog import Ui_UnittestStacktraceDialog self.dlg = QDialog(self) @@ -648,7 +656,7 @@ # and now fire it up self.dlg.show() self.dlg.exec_() - + def __showSource(self): """ Private slot to show the source of a traceback in an eric6 editor. @@ -727,7 +735,7 @@ """ super(QtTestResult, self).__init__() self.parent = parent - + def addFailure(self, test, err): """ Public method called if a test failed. @@ -738,7 +746,7 @@ super(QtTestResult, self).addFailure(test, err) tracebackLines = self._exc_info_to_string(err, test) self.parent.testFailed(str(test), tracebackLines, test.id()) - + def addError(self, test, err): """ Public method called if a test errored. @@ -749,7 +757,7 @@ super(QtTestResult, self).addError(test, err) tracebackLines = self._exc_info_to_string(err, test) self.parent.testErrored(str(test), tracebackLines, test.id()) - + def addSkip(self, test, reason): """ Public method called if a test was skipped. @@ -759,7 +767,7 @@ """ super(QtTestResult, self).addSkip(test, reason) self.parent.testSkipped(str(test), reason, test.id()) - + def addExpectedFailure(self, test, err): """ Public method called if a test failed expected. @@ -770,7 +778,7 @@ super(QtTestResult, self).addExpectedFailure(test, err) tracebackLines = self._exc_info_to_string(err, test) self.parent.testFailedExpected(str(test), tracebackLines, test.id()) - + def addUnexpectedSuccess(self, test): """ Public method called if a test succeeded expectedly. @@ -779,7 +787,7 @@ """ super(QtTestResult, self).addUnexpectedSuccess(test) self.parent.testSucceededUnexpected(str(test), test.id()) - + def startTest(self, test): """ Public method called at the start of a test.