200 # we are called from within the eric IDE |
200 # we are called from within the eric IDE |
201 self.__venvManager = ericApp().getObject("VirtualEnvManager") |
201 self.__venvManager = ericApp().getObject("VirtualEnvManager") |
202 self.__project = ericApp().getObject("Project") |
202 self.__project = ericApp().getObject("Project") |
203 self.__project.projectOpened.connect(self.__projectOpened) |
203 self.__project.projectOpened.connect(self.__projectOpened) |
204 self.__project.projectClosed.connect(self.__projectClosed) |
204 self.__project.projectClosed.connect(self.__projectClosed) |
205 self.__projectEnvironmentMarker = self.tr("<project>") |
|
206 except KeyError: |
205 except KeyError: |
207 # we were called as a standalone application |
206 # we were called as a standalone application |
208 from eric7.VirtualEnv.VirtualenvManager import ( # __IGNORE_WARNING_I101__ |
207 from eric7.VirtualEnv.VirtualenvManager import ( # __IGNORE_WARNING_I101__ |
209 VirtualenvManager, |
208 VirtualenvManager, |
210 ) |
209 ) |
220 self.__populateVenvComboBox |
219 self.__populateVenvComboBox |
221 ) |
220 ) |
222 ericApp().registerObject("VirtualEnvManager", self.__venvManager) |
221 ericApp().registerObject("VirtualEnvManager", self.__venvManager) |
223 |
222 |
224 self.__project = None |
223 self.__project = None |
225 self.__projectEnvironmentMarker = "" |
224 |
|
225 self.debuggerCheckBox.setChecked(False) |
|
226 self.debuggerCheckBox.setVisible(False) |
226 |
227 |
227 self.__discoverHistory = [] |
228 self.__discoverHistory = [] |
228 self.__fileHistory = [] |
229 self.__fileHistory = [] |
229 self.__testNameHistory = [] |
230 self.__testNameHistory = [] |
230 self.__recentFramework = "" |
231 self.__recentFramework = "" |
277 @param venvName name of the virtual environment |
278 @param venvName name of the virtual environment |
278 @type str |
279 @type str |
279 @return path of the interpreter executable |
280 @return path of the interpreter executable |
280 @rtype str |
281 @rtype str |
281 """ |
282 """ |
282 if self.__project and venvName == self.__projectEnvironmentMarker: |
283 if ( |
|
284 self.__project |
|
285 and venvName == ericApp().getObject("DebugUI").getProjectEnvironmentString() |
|
286 ): |
283 return self.__project.getProjectInterpreter() |
287 return self.__project.getProjectInterpreter() |
284 else: |
288 else: |
285 return self.__venvManager.getVirtualenvInterpreter(venvName) |
289 return self.__venvManager.getVirtualenvInterpreter(venvName) |
286 |
290 |
287 def __populateVenvComboBox(self): |
291 def __populateVenvComboBox(self): |
293 currentText = self.__recentEnvironment |
297 currentText = self.__recentEnvironment |
294 |
298 |
295 self.venvComboBox.clear() |
299 self.venvComboBox.clear() |
296 self.venvComboBox.addItem("") |
300 self.venvComboBox.addItem("") |
297 if self.__project and self.__project.isOpen(): |
301 if self.__project and self.__project.isOpen(): |
298 self.venvComboBox.addItem(self.__projectEnvironmentMarker) |
302 venvName = ericApp().getObject("DebugUI").getProjectEnvironmentString() |
|
303 if venvName: |
|
304 self.venvComboBox.addItem(venvName) |
299 self.venvComboBox.addItems(sorted(self.__venvManager.getVirtualenvNames())) |
305 self.venvComboBox.addItems(sorted(self.__venvManager.getVirtualenvNames())) |
300 self.venvComboBox.setCurrentText(currentText) |
306 self.venvComboBox.setCurrentText(currentText) |
301 |
307 |
302 def __populateTestFrameworkComboBox(self): |
308 def __populateTestFrameworkComboBox(self): |
303 """ |
309 """ |
736 @type QAbstractButton |
742 @type QAbstractButton |
737 """ |
743 """ |
738 if button == self.__discoverButton: |
744 if button == self.__discoverButton: |
739 self.__discoverTests() |
745 self.__discoverTests() |
740 if button == self.__startButton: |
746 if button == self.__startButton: |
741 self.startTests() |
747 self.startTests(debug=self.debuggerCheckBox.isChecked()) |
742 self.__saveRecent() |
748 self.__saveRecent() |
743 elif button == self.__stopButton: |
749 elif button == self.__stopButton: |
744 self.__stopTests() |
750 self.__stopTests() |
745 elif button == self.__startFailedButton: |
751 elif button == self.__startFailedButton: |
746 self.startTests(failedOnly=True) |
752 self.startTests(failedOnly=True, debug=self.debuggerCheckBox.isChecked()) |
747 elif button == self.__showCoverageButton: |
753 elif button == self.__showCoverageButton: |
748 self.__showCoverageDialog() |
754 self.__showCoverageDialog() |
749 elif button == self.__showLogButton: |
755 elif button == self.__showLogButton: |
750 self.__showLogOutput() |
756 self.__showLogOutput() |
751 |
757 |
946 |
952 |
947 self.__setDiscoverMode() |
953 self.__setDiscoverMode() |
948 self.__testExecutor.discover(config, []) |
954 self.__testExecutor.discover(config, []) |
949 |
955 |
950 @pyqtSlot() |
956 @pyqtSlot() |
951 def startTests(self, failedOnly=False): |
957 def startTests(self, failedOnly=False, debug=False): |
952 """ |
958 """ |
953 Public slot to start the test run. |
959 Public slot to start the test run. |
954 |
960 |
955 @param failedOnly flag indicating to run only failed tests |
961 @param failedOnly flag indicating to run only failed tests (defaults to False) |
956 @type bool |
962 @type bool (optional) |
|
963 @param debug flag indicating to start the test run with debugger support |
|
964 (defaults to False) |
|
965 @type bool (optional) |
957 """ |
966 """ |
958 if self.__mode in (TestingWidgetModes.RUNNING, TestingWidgetModes.DISCOVERY): |
967 if self.__mode in (TestingWidgetModes.RUNNING, TestingWidgetModes.DISCOVERY): |
959 return |
968 return |
960 |
969 |
961 self.__recentLog = "" |
970 self.__recentLog = "" |
990 os.path.splitext(mainScript)[0] + ".coverage" if mainScript else "" |
999 os.path.splitext(mainScript)[0] + ".coverage" if mainScript else "" |
991 ) |
1000 ) |
992 else: |
1001 else: |
993 coverageFile = "" |
1002 coverageFile = "" |
994 interpreter = self.__determineInterpreter(self.__recentEnvironment) |
1003 interpreter = self.__determineInterpreter(self.__recentEnvironment) |
|
1004 |
995 testCases = self.__selectedTestCases() |
1005 testCases = self.__selectedTestCases() |
996 if not testCases and self.discoveryList.topLevelItemCount() > 0: |
1006 if not testCases and self.discoveryList.topLevelItemCount() > 0: |
997 ok = EricMessageBox.yesNo( |
1007 ok = EricMessageBox.yesNo( |
998 self, |
1008 self, |
999 self.tr("Running Tests"), |
1009 self.tr("Running Tests"), |
1014 failFast=self.failfastCheckBox.isChecked(), |
1024 failFast=self.failfastCheckBox.isChecked(), |
1015 failedOnly=failedOnly, |
1025 failedOnly=failedOnly, |
1016 collectCoverage=self.coverageCheckBox.isChecked(), |
1026 collectCoverage=self.coverageCheckBox.isChecked(), |
1017 eraseCoverage=self.coverageEraseCheckBox.isChecked(), |
1027 eraseCoverage=self.coverageEraseCheckBox.isChecked(), |
1018 coverageFile=coverageFile, |
1028 coverageFile=coverageFile, |
|
1029 venvName=self.__recentEnvironment, |
1019 ) |
1030 ) |
1020 |
1031 |
1021 self.__testExecutor = self.__frameworkRegistry.createExecutor( |
1032 self.__testExecutor = self.__frameworkRegistry.createExecutor( |
1022 self.__recentFramework, self |
1033 self.__recentFramework, self |
1023 ) |
1034 ) |
1032 self.__testExecutor.testRunAboutToBeStarted.connect( |
1043 self.__testExecutor.testRunAboutToBeStarted.connect( |
1033 self.__testRunAboutToBeStarted |
1044 self.__testRunAboutToBeStarted |
1034 ) |
1045 ) |
1035 |
1046 |
1036 self.__setRunningMode() |
1047 self.__setRunningMode() |
1037 self.__testExecutor.start(config, []) |
1048 if debug: |
|
1049 self.__testExecutor.startDebug(config, [], ericApp().getObject("DebugUI")) |
|
1050 else: |
|
1051 self.__testExecutor.start(config, []) |
1038 |
1052 |
1039 @pyqtSlot() |
1053 @pyqtSlot() |
1040 def __stopTests(self): |
1054 def __stopTests(self): |
1041 """ |
1055 """ |
1042 Private slot to stop the current test run. |
1056 Private slot to stop the current test run. |
1266 @pyqtSlot() |
1280 @pyqtSlot() |
1267 def __projectOpened(self): |
1281 def __projectOpened(self): |
1268 """ |
1282 """ |
1269 Private slot to handle a project being opened. |
1283 Private slot to handle a project being opened. |
1270 """ |
1284 """ |
1271 self.venvComboBox.insertItem(1, self.__projectEnvironmentMarker) |
1285 self.venvComboBox.insertItem( |
|
1286 1, ericApp().getObject("DebugUI").getProjectEnvironmentString() |
|
1287 ) |
1272 self.venvComboBox.setCurrentIndex(1) |
1288 self.venvComboBox.setCurrentIndex(1) |
1273 self.frameworkComboBox.setCurrentText( |
1289 self.frameworkComboBox.setCurrentText( |
1274 self.__project.getProjectTestingFramework() |
1290 self.__project.getProjectTestingFramework() |
1275 ) |
1291 ) |
1276 self.__insertDiscovery(self.__project.getProjectPath()) |
1292 self.__insertDiscovery(self.__project.getProjectPath()) |