def _makeRunnerConfigButton(self): currentRunner = self._setInitialTestMode() currentRunnerMode = currentRunner.mode() self._runnerConfigBtn, self._configMenu = uiutils.makeMenuToolButton( parent=self) self._updateConfigButton(currentRunner) for runner in self._testManager.iterAllRunners(): icon = runner.icon() toolTip = "Run tests using {}.".format(runner.name()) runnerMode = runner.mode() act = QtWidgets.QAction(runner.name(), self) act.setIcon(icon) act.setEnabled(runner.isValid()) act.setToolTip(toolTip) act.setData(runnerMode) act.triggered.connect(self._onTestRunnerSwitched) self._updateLabelOfTestRunnerAct(act, currentRunnerMode) self._testRunnerActions.append(act) self._configMenu.addAction(act) self._configMenu.addSeparator() # Stop on error act: self._stopOnErrorAct, stopOnError = self._addToggleConfigAction( "Stop On Error", self._stopAtErrorIcon, "Stop the tests running once it encounters a test error/failure.", configKey=constants.CONFIG_KEY_STOP_ON_ERROR, slot=self._onStopOnErrorActionToggled, ) self._testManager.setStopOnError(stopOnError) # auto filer on run act: self._autoFilterAct, stopOnError = self._addToggleConfigAction( "Only Show Tests that Run", self._autoFilterIcon, "Apply a ':ran' filter automatically after every test run so that only the run tests shown in the view.", configKey=constants.CONFIG_KEY_AUTO_FILTERING_STATE, slot=self._onAutoFilterActionToggled, ) # auto clear log on run act: self._clearLogOnRunAct, stopOnError = self._addToggleConfigAction( "Clear LogBrowser On Run", self._clearLogOnRunIcon, "Clear the log browser automatically before every test run.", configKey=constants.CONFIG_KEY_AUTO_CLEAR_LOG_STATE, slot=self._onAutoClearLogActionToggled, ) self._configMenu.addSeparator() act = self._configMenu.addAction("Preference..") act.setIcon(self._configIcon) act.triggered.connect(self._showConfigWindow)
def _addToggleConfigAction(self, lbl, icon, tooltip, configKey, slot): # Cannot use self._configMenu.addAction() directly here since over-zealous garbage collection in some DCC apps: act = QtWidgets.QAction(lbl, self) act.setIcon(icon) act.setCheckable(True) act.setToolTip(tooltip) act.toggled.connect(slot) value = appsettings.get().simpleConfigBoolValue(configKey) act.setChecked(value) self._configMenu.addAction(act) return (act, value)
def _makeRunMoreButton(self): _runMoreBtn = QtWidgets.QToolButton(self) _runMoreBtn.setIcon(self._view._runPartialIcon) _runMoreBtn.setAutoRaise(True) _runMoreBtn.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) _runMoreBtn.setPopupMode(_runMoreBtn.InstantPopup) self._runSetupAct = QtWidgets.QAction("Run setUp( ) Only", self) self._runSetupAct.setIcon(self._view._runPartialIcon) self._runSetupAct.triggered.connect(self._runTestSetupOnly) self._runNoTearDown = QtWidgets.QAction("Run without tearDown( )", self) self._runNoTearDown.setIcon(self._view._runPartialIcon) self._runNoTearDown.triggered.connect(self._runTestWithoutTearDown) menu = QtWidgets.QMenu(_runMoreBtn) menu.addAction(self._runSetupAct) menu.addAction(self._runNoTearDown) _runMoreBtn.setMenu(menu) return _runMoreBtn
def _makeContextMenu(self): self._initAllIcons() self._runSetupOnlyAct = QtWidgets.QAction("Run setUp( ) Only", self) self._runSetupOnlyAct.triggered.connect(self._atRunSetupOnly) self._runSetupOnlyAct.setIcon(self._runPartialIcon) self._runWithoutTearDownAct = QtWidgets.QAction("Run Without tearDown( )", self) self._runWithoutTearDownAct.triggered.connect(self._atRunWithoutTearDown) self._runWithoutTearDownAct.setIcon(self._runPartialIcon) self._runSelectedAct = QtWidgets.QAction("Run Selected", self) self._runSelectedAct.triggered.connect(self._atRunSelected) self._runSelectedAct.setIcon(self._runSelectedIcon) self._runAllAct = QtWidgets.QAction("Run All", self) self._runAllAct.triggered.connect(self._atRunAll) self._runAllAct.setIcon(self._runAllIcon) self._copyPathAct = QtWidgets.QAction("Copy Selected Path", self) self._copyPathAct.triggered.connect(self.copyFirstSelectedTestId) self._goToCodeAct = QtWidgets.QAction("Go To Code...", self) self._goToCodeAct.triggered.connect(self._atGoToCode) self._reloadModulesAct = QtWidgets.QAction("Reload Selected Modules", self) self._reloadModulesAct.setVisible( importutils.isReimportFeatureAvailable(silentCheck=True) ) self._reloadModulesAct.triggered.connect(self._atReloadSelectedModules) self._reloadModulesAct.setIcon(self._reimportAndRunIcon) self._contextMenu.addAction(self._runAllAct) self._contextMenu.addAction(self._runSelectedAct) self._contextMenu.addSeparator() self._contextMenu.addAction(self._runSetupOnlyAct) self._contextMenu.addAction(self._runWithoutTearDownAct) self._contextMenu.addSeparator() self._contextMenu.addAction(self._copyPathAct) self._contextMenu.addAction(self._goToCodeAct) self._contextMenu.addSeparator() self._contextMenu.addAction(self._reloadModulesAct) self._logLevelMenu = QtWidgets.QMenu("Set Logging Level") self._contextMenu.addMenu(self._logLevelMenu) self._logLevelActionGrp = QtWidgets.QActionGroup(self._logLevelMenu) self._logLevelActionGrp.setExclusive(True)