2508 """<p>Opens a dialog to send a feature request.</p>""" |
2509 """<p>Opens a dialog to send a feature request.</p>""" |
2509 )) |
2510 )) |
2510 self.requestFeatureAct.triggered.connect(self.__requestFeature) |
2511 self.requestFeatureAct.triggered.connect(self.__requestFeature) |
2511 self.actions.append(self.requestFeatureAct) |
2512 self.actions.append(self.requestFeatureAct) |
2512 |
2513 |
2513 self.utActGrp = createActionGroup(self) |
2514 self.testingActGrp = createActionGroup(self) |
2514 |
2515 |
2515 self.utDialogAct = EricAction( |
2516 self.testingDialogAct = EricAction( |
2516 self.tr('Unittest'), |
2517 self.tr('Testing'), |
2517 UI.PixmapCache.getIcon("unittest"), |
2518 UI.PixmapCache.getIcon("unittest"), |
2518 self.tr('&Unittest...'), |
2519 self.tr('&Testing...'), |
2519 0, 0, self.utActGrp, 'unittest') |
2520 0, 0, self.testingActGrp, 'unittest') |
2520 self.utDialogAct.setStatusTip(self.tr('Start unittest dialog')) |
2521 self.testingDialogAct.setStatusTip(self.tr('Start the testing dialog')) |
2521 self.utDialogAct.setWhatsThis(self.tr( |
2522 self.testingDialogAct.setWhatsThis(self.tr( |
2522 """<b>Unittest</b>""" |
2523 """<b>Testing</b>""" |
2523 """<p>Perform unit tests. The dialog gives the""" |
2524 """<p>Perform test runss. The dialog gives the""" |
2524 """ ability to select and run a unittest suite or""" |
2525 """ ability to select and run a test suite or""" |
2525 """auto discover them.</p>""" |
2526 """auto discover them.</p>""" |
2526 )) |
2527 )) |
2527 self.utDialogAct.triggered.connect(self.__unittest) |
2528 self.testingDialogAct.triggered.connect(self.__startTesting) |
2528 self.actions.append(self.utDialogAct) |
2529 self.actions.append(self.testingDialogAct) |
2529 |
2530 |
2530 self.utRestartAct = EricAction( |
2531 self.restartTestAct = EricAction( |
2531 self.tr('Unittest Restart'), |
2532 self.tr('Restart Last Test'), |
2532 UI.PixmapCache.getIcon("unittestRestart"), |
2533 UI.PixmapCache.getIcon("unittestRestart"), |
2533 self.tr('&Restart Unittest...'), |
2534 self.tr('&Restart Last Test...'), |
2534 0, 0, self.utActGrp, 'unittest_restart') |
2535 0, 0, self.testingActGrp, 'unittest_restart') |
2535 self.utRestartAct.setStatusTip(self.tr('Restart last unittest')) |
2536 self.restartTestAct.setStatusTip(self.tr('Restarts the last test')) |
2536 self.utRestartAct.setWhatsThis(self.tr( |
2537 self.restartTestAct.setWhatsThis(self.tr( |
2537 """<b>Restart Unittest</b>""" |
2538 """<b>Restart Last Test</b>""" |
2538 """<p>Restart the unittest performed last.</p>""" |
2539 """<p>Restarts the test performed last.</p>""" |
2539 )) |
2540 )) |
2540 self.utRestartAct.triggered.connect(self.__unittestRestart) |
2541 self.restartTestAct.triggered.connect(self.__restartTest) |
2541 self.utRestartAct.setEnabled(False) |
2542 self.restartTestAct.setEnabled(False) |
2542 self.actions.append(self.utRestartAct) |
2543 self.actions.append(self.restartTestAct) |
2543 |
2544 |
2544 self.utRerunFailedAct = EricAction( |
2545 self.rerunFailedTestsAct = EricAction( |
2545 self.tr('Unittest Rerun Failed'), |
2546 self.tr('Rerun Failed Tests'), |
2546 UI.PixmapCache.getIcon("unittestRerunFailed"), |
2547 UI.PixmapCache.getIcon("unittestRerunFailed"), |
2547 self.tr('Rerun Failed Tests...'), |
2548 self.tr('Rerun Failed Tests...'), |
2548 0, 0, self.utActGrp, 'unittest_rerun_failed') |
2549 0, 0, self.testingActGrp, 'unittest_rerun_failed') |
2549 self.utRerunFailedAct.setStatusTip(self.tr( |
2550 self.rerunFailedTestsAct.setStatusTip(self.tr( |
2550 'Rerun failed tests of the last run')) |
2551 'Rerun failed tests of the last run')) |
2551 self.utRerunFailedAct.setWhatsThis(self.tr( |
2552 self.rerunFailedTestsAct.setWhatsThis(self.tr( |
2552 """<b>Rerun Failed Tests</b>""" |
2553 """<b>Rerun Failed Tests</b>""" |
2553 """<p>Rerun all tests that failed during the last unittest""" |
2554 """<p>Rerun all tests that failed during the last test run.</p>""" |
2554 """ run.</p>""" |
|
2555 )) |
2555 )) |
2556 self.utRerunFailedAct.triggered.connect(self.__unittestRerunFailed) |
2556 self.rerunFailedTestsAct.triggered.connect(self.__rerunFailedTests) |
2557 self.utRerunFailedAct.setEnabled(False) |
2557 self.rerunFailedTestsAct.setEnabled(False) |
2558 self.actions.append(self.utRerunFailedAct) |
2558 self.actions.append(self.rerunFailedTestsAct) |
2559 |
2559 |
2560 self.utScriptAct = EricAction( |
2560 self.testScriptAct = EricAction( |
2561 self.tr('Unittest Script'), |
2561 self.tr('Test Script'), |
2562 UI.PixmapCache.getIcon("unittestScript"), |
2562 UI.PixmapCache.getIcon("unittestScript"), |
2563 self.tr('Unittest &Script...'), |
2563 self.tr('Test &Script...'), |
2564 0, 0, self.utActGrp, 'unittest_script') |
2564 0, 0, self.testingActGrp, 'unittest_script') |
2565 self.utScriptAct.setStatusTip(self.tr( |
2565 self.testScriptAct.setStatusTip(self.tr( |
2566 'Run unittest with current script')) |
2566 'Run tests of the current script')) |
2567 self.utScriptAct.setWhatsThis(self.tr( |
2567 self.testScriptAct.setWhatsThis(self.tr( |
2568 """<b>Unittest Script</b>""" |
2568 """<b>Test Script</b>""" |
2569 """<p>Run unittest with current script.</p>""" |
2569 """<p>Run tests with the current script.</p>""" |
2570 )) |
2570 )) |
2571 self.utScriptAct.triggered.connect(self.__unittestScript) |
2571 self.testScriptAct.triggered.connect(self.__startTestScript) |
2572 self.utScriptAct.setEnabled(False) |
2572 self.testScriptAct.setEnabled(False) |
2573 self.actions.append(self.utScriptAct) |
2573 self.actions.append(self.testScriptAct) |
2574 |
2574 |
2575 self.utProjectAct = EricAction( |
2575 self.testProjectAct = EricAction( |
2576 self.tr('Unittest Project'), |
2576 self.tr('Test Project'), |
2577 UI.PixmapCache.getIcon("unittestProject"), |
2577 UI.PixmapCache.getIcon("unittestProject"), |
2578 self.tr('Unittest &Project...'), |
2578 self.tr('Test &Project...'), |
2579 0, 0, self.utActGrp, 'unittest_project') |
2579 0, 0, self.testingActGrp, 'unittest_project') |
2580 self.utProjectAct.setStatusTip(self.tr( |
2580 self.testProjectAct.setStatusTip(self.tr( |
2581 'Run unittest with current project')) |
2581 'Run tests of the current project')) |
2582 self.utProjectAct.setWhatsThis(self.tr( |
2582 self.testProjectAct.setWhatsThis(self.tr( |
2583 """<b>Unittest Project</b>""" |
2583 """<b>Test Project</b>""" |
2584 """<p>Run unittest with current project.</p>""" |
2584 """<p>Run test of the current project.</p>""" |
2585 )) |
2585 )) |
2586 self.utProjectAct.triggered.connect(self.__unittestProject) |
2586 self.testProjectAct.triggered.connect(self.__startTestProject) |
2587 self.utProjectAct.setEnabled(False) |
2587 self.testProjectAct.setEnabled(False) |
2588 self.actions.append(self.utProjectAct) |
2588 self.actions.append(self.testProjectAct) |
2589 |
2589 |
2590 # check for Qt5 designer and linguist |
2590 # check for Qt5 designer and linguist |
2591 if Utilities.isWindowsPlatform(): |
2591 if Utilities.isWindowsPlatform(): |
2592 designerExe = os.path.join( |
2592 designerExe = os.path.join( |
2593 Utilities.getQtBinariesPath(), |
2593 Utilities.getQtBinariesPath(), |
3398 |
3398 |
3399 ############################################################## |
3399 ############################################################## |
3400 ## Extras/Unittest menu |
3400 ## Extras/Unittest menu |
3401 ############################################################## |
3401 ############################################################## |
3402 |
3402 |
3403 self.__menus["unittest"] = QMenu(self.tr('&Unittest'), self) |
3403 self.__menus["testing"] = QMenu(self.tr('&Testing'), self) |
3404 self.__menus["unittest"].setTearOffEnabled(True) |
3404 self.__menus["testing"].setTearOffEnabled(True) |
3405 self.__menus["unittest"].addAction(self.utDialogAct) |
3405 self.__menus["testing"].addAction(self.testingDialogAct) |
3406 self.__menus["unittest"].addSeparator() |
3406 self.__menus["testing"].addSeparator() |
3407 self.__menus["unittest"].addAction(self.utRestartAct) |
3407 self.__menus["testing"].addAction(self.restartTestAct) |
3408 self.__menus["unittest"].addAction(self.utRerunFailedAct) |
3408 self.__menus["testing"].addAction(self.rerunFailedTestsAct) |
3409 self.__menus["unittest"].addSeparator() |
3409 self.__menus["testing"].addSeparator() |
3410 self.__menus["unittest"].addAction(self.utScriptAct) |
3410 self.__menus["testing"].addAction(self.testScriptAct) |
3411 self.__menus["unittest"].addAction(self.utProjectAct) |
3411 self.__menus["testing"].addAction(self.testProjectAct) |
3412 |
3412 |
3413 self.__menus["extras"].addMenu(self.__menus["unittest"]) |
3413 self.__menus["extras"].addMenu(self.__menus["testing"]) |
3414 self.__menus["extras"].addSeparator() |
3414 self.__menus["extras"].addSeparator() |
3415 |
3415 |
3416 ############################################################## |
3416 ############################################################## |
3417 ## Extras/Builtin,Plugin,User tools menus |
3417 ## Extras/Builtin,Plugin,User tools menus |
3418 ############################################################## |
3418 ############################################################## |
3596 viewtb = self.viewmanager.initViewToolbar(self.toolbarManager) |
3596 viewtb = self.viewmanager.initViewToolbar(self.toolbarManager) |
3597 starttb, debugtb = self.debuggerUI.initToolbars(self.toolbarManager) |
3597 starttb, debugtb = self.debuggerUI.initToolbars(self.toolbarManager) |
3598 multiprojecttb = self.multiProject.initToolbar(self.toolbarManager) |
3598 multiprojecttb = self.multiProject.initToolbar(self.toolbarManager) |
3599 projecttb, vcstb = self.project.initToolbars(self.toolbarManager) |
3599 projecttb, vcstb = self.project.initToolbars(self.toolbarManager) |
3600 toolstb = QToolBar(self.tr("Tools"), self) |
3600 toolstb = QToolBar(self.tr("Tools"), self) |
3601 unittesttb = QToolBar(self.tr("Unittest"), self) |
3601 testingtb = QToolBar(self.tr("Testing"), self) |
3602 bookmarktb = self.viewmanager.initBookmarkToolbar(self.toolbarManager) |
3602 bookmarktb = self.viewmanager.initBookmarkToolbar(self.toolbarManager) |
3603 spellingtb = self.viewmanager.initSpellingToolbar(self.toolbarManager) |
3603 spellingtb = self.viewmanager.initSpellingToolbar(self.toolbarManager) |
3604 settingstb = QToolBar(self.tr("Settings"), self) |
3604 settingstb = QToolBar(self.tr("Settings"), self) |
3605 helptb = QToolBar(self.tr("Help"), self) |
3605 helptb = QToolBar(self.tr("Help"), self) |
3606 profilestb = QToolBar(self.tr("Profiles"), self) |
3606 profilestb = QToolBar(self.tr("Profiles"), self) |
3607 pluginstb = QToolBar(self.tr("Plugins"), self) |
3607 pluginstb = QToolBar(self.tr("Plugins"), self) |
3608 |
3608 |
3609 toolstb.setIconSize(Config.ToolBarIconSize) |
3609 toolstb.setIconSize(Config.ToolBarIconSize) |
3610 unittesttb.setIconSize(Config.ToolBarIconSize) |
3610 testingtb.setIconSize(Config.ToolBarIconSize) |
3611 settingstb.setIconSize(Config.ToolBarIconSize) |
3611 settingstb.setIconSize(Config.ToolBarIconSize) |
3612 helptb.setIconSize(Config.ToolBarIconSize) |
3612 helptb.setIconSize(Config.ToolBarIconSize) |
3613 profilestb.setIconSize(Config.ToolBarIconSize) |
3613 profilestb.setIconSize(Config.ToolBarIconSize) |
3614 pluginstb.setIconSize(Config.ToolBarIconSize) |
3614 pluginstb.setIconSize(Config.ToolBarIconSize) |
3615 |
3615 |
3616 toolstb.setObjectName("ToolsToolbar") |
3616 toolstb.setObjectName("ToolsToolbar") |
3617 unittesttb.setObjectName("UnittestToolbar") |
3617 testingtb.setObjectName("UnittestToolbar") |
3618 settingstb.setObjectName("SettingsToolbar") |
3618 settingstb.setObjectName("SettingsToolbar") |
3619 helptb.setObjectName("HelpToolbar") |
3619 helptb.setObjectName("HelpToolbar") |
3620 profilestb.setObjectName("ProfilesToolbar") |
3620 profilestb.setObjectName("ProfilesToolbar") |
3621 pluginstb.setObjectName("PluginsToolbar") |
3621 pluginstb.setObjectName("PluginsToolbar") |
3622 |
3622 |
3623 toolstb.setToolTip(self.tr("Tools")) |
3623 toolstb.setToolTip(self.tr("Tools")) |
3624 unittesttb.setToolTip(self.tr("Unittest")) |
3624 testingtb.setToolTip(self.tr("Unittest")) |
3625 settingstb.setToolTip(self.tr("Settings")) |
3625 settingstb.setToolTip(self.tr("Settings")) |
3626 helptb.setToolTip(self.tr("Help")) |
3626 helptb.setToolTip(self.tr("Help")) |
3627 profilestb.setToolTip(self.tr("Profiles")) |
3627 profilestb.setToolTip(self.tr("Profiles")) |
3628 pluginstb.setToolTip(self.tr("Plugins")) |
3628 pluginstb.setToolTip(self.tr("Plugins")) |
3629 |
3629 |
3633 act = filetb.actions()[0] |
3633 act = filetb.actions()[0] |
3634 sep = filetb.insertSeparator(act) |
3634 sep = filetb.insertSeparator(act) |
3635 filetb.insertAction(sep, self.newWindowAct) |
3635 filetb.insertAction(sep, self.newWindowAct) |
3636 self.toolbarManager.addToolBar(filetb, filetb.windowTitle()) |
3636 self.toolbarManager.addToolBar(filetb, filetb.windowTitle()) |
3637 |
3637 |
3638 # setup the unittest toolbar |
3638 # setup the testing toolbar |
3639 unittesttb.addAction(self.utDialogAct) |
3639 testingtb.addAction(self.testingDialogAct) |
3640 unittesttb.addSeparator() |
3640 testingtb.addSeparator() |
3641 unittesttb.addAction(self.utRestartAct) |
3641 testingtb.addAction(self.restartTestAct) |
3642 unittesttb.addAction(self.utRerunFailedAct) |
3642 testingtb.addAction(self.rerunFailedTestsAct) |
3643 unittesttb.addSeparator() |
3643 testingtb.addSeparator() |
3644 unittesttb.addAction(self.utScriptAct) |
3644 testingtb.addAction(self.testScriptAct) |
3645 unittesttb.addAction(self.utProjectAct) |
3645 testingtb.addAction(self.testProjectAct) |
3646 self.toolbarManager.addToolBar(unittesttb, unittesttb.windowTitle()) |
3646 self.toolbarManager.addToolBar(testingtb, testingtb.windowTitle()) |
3647 |
3647 |
3648 # setup the tools toolbar |
3648 # setup the tools toolbar |
3649 if self.designer4Act is not None: |
3649 if self.designer4Act is not None: |
3650 toolstb.addAction(self.designer4Act) |
3650 toolstb.addAction(self.designer4Act) |
3651 if self.linguist4Act is not None: |
3651 if self.linguist4Act is not None: |
5331 dlg = ToolGroupConfigurationDialog( |
5330 dlg = ToolGroupConfigurationDialog( |
5332 self.toolGroups, self.currentToolGroup, self) |
5331 self.toolGroups, self.currentToolGroup, self) |
5333 if dlg.exec() == QDialog.DialogCode.Accepted: |
5332 if dlg.exec() == QDialog.DialogCode.Accepted: |
5334 self.toolGroups, self.currentToolGroup = dlg.getToolGroups() |
5333 self.toolGroups, self.currentToolGroup = dlg.getToolGroups() |
5335 |
5334 |
5336 def __createUnitTestDialog(self): |
5335 def __createTestingDialog(self): |
5337 """ |
5336 """ |
5338 Private slot to generate the unit test dialog on demand. |
5337 Private slot to generate the testing dialog on demand. |
5339 """ |
5338 """ |
5340 if self.__unittestWidget is None: |
5339 if self.__testingWidget is None: |
5341 from Unittest.UnittestWidget import UnittestWidget |
5340 from Testing.TestingWidget import TestingWidget |
5342 self.__unittestWidget = UnittestWidget() |
5341 self.__testingWidget = TestingWidget() |
5343 self.__unittestWidget.unittestFile.connect( |
5342 self.__testingWidget.testFile.connect( |
5344 self.viewmanager.setFileLine) |
5343 self.viewmanager.setFileLine) |
5345 self.__unittestWidget.unittestStopped.connect( |
5344 self.__testingWidget.testRunStopped.connect( |
5346 self.__unittestStopped) |
5345 self.__testingStopped) |
5347 |
5346 |
5348 def __unittestStopped(self): |
5347 def __testingStopped(self): |
5349 """ |
5348 """ |
5350 Private slot to handle the end of a unit test run. |
5349 Private slot to handle the end of a test run. |
5351 """ |
5350 """ |
5352 self.utRerunFailedAct.setEnabled( |
5351 self.rerunFailedTestsAct.setEnabled( |
5353 self.__unittestWidget.hasFailedTests()) |
5352 self.__testingWidget.hasFailedTests()) |
5354 self.utRestartAct.setEnabled(True) |
5353 self.restartTestAct.setEnabled(True) |
5355 |
5354 |
5356 def __unittest(self): |
5355 def __startTesting(self): |
5357 """ |
5356 """ |
5358 Private slot for displaying the unittest dialog. |
5357 Private slot for displaying the testing dialog. |
5359 """ |
5358 """ |
5360 self.__createUnitTestDialog() |
5359 self.__createTestingDialog() |
5361 self.__unittestWidget.show() |
5360 self.__testingWidget.show() |
5362 self.__unittestWidget.raise_() |
5361 self.__testingWidget.raise_() |
5363 |
5362 |
5364 @pyqtSlot() |
5363 @pyqtSlot() |
5365 @pyqtSlot(str) |
5364 @pyqtSlot(str) |
5366 def __unittestScript(self, testFile=None): |
5365 def __startTestScript(self, testFile=None): |
5367 """ |
5366 """ |
5368 Private slot for displaying the unittest dialog and run the current |
5367 Private slot for displaying the testing dialog and run the current |
5369 script. |
5368 script. |
5370 |
5369 |
5371 @param testFile file containing the unit tests to be run |
5370 @param testFile file containing the tests to be run |
5372 @type str |
5371 @type str |
5373 """ |
5372 """ |
5374 if testFile is None: |
5373 if testFile is None: |
5375 aw = self.viewmanager.activeWindow() |
5374 aw = self.viewmanager.activeWindow() |
5376 fn = aw.getFileName() |
5375 fn = aw.getFileName() |
5378 if os.path.exists(tfn): |
5377 if os.path.exists(tfn): |
5379 testFile = tfn |
5378 testFile = tfn |
5380 else: |
5379 else: |
5381 testFile = fn |
5380 testFile = fn |
5382 |
5381 |
5383 self.__unittest() |
5382 self.__startTesting() |
5384 self.__unittestWidget.setTestFile(testFile) |
5383 self.__testingWidget.setTestFile(testFile) |
5385 self.utRestartAct.setEnabled(False) |
5384 self.restartTestAct.setEnabled(False) |
5386 self.utRerunFailedAct.setEnabled(False) |
5385 self.rerunFailedTestsAct.setEnabled(False) |
5387 |
5386 |
5388 @pyqtSlot() |
5387 @pyqtSlot() |
5389 def __unittestProject(self): |
5388 def __startTestProject(self): |
5390 """ |
5389 """ |
5391 Private slot for displaying the unittest dialog and run the current |
5390 Private slot for displaying the testing dialog and run the test for |
5392 project. |
5391 the current project. |
5393 """ |
5392 """ |
5394 testFile = None |
5393 testFile = None |
5395 fn = self.project.getMainScript(True) |
5394 fn = self.project.getMainScript(True) |
5396 if fn: |
5395 if fn: |
5397 tfn = Utilities.getTestFileName(fn) |
5396 tfn = Utilities.getTestFileName(fn) |
5398 if os.path.exists(tfn): |
5397 if os.path.exists(tfn): |
5399 testFile = tfn |
5398 testFile = tfn |
5400 |
5399 |
5401 self.__unittest() |
5400 self.__startTesting() |
5402 self.__unittestWidget.setTestFile(testFile) |
5401 self.__testingWidget.setTestFile(testFile) |
5403 self.utRestartAct.setEnabled(False) |
5402 self.restartTestAct.setEnabled(False) |
5404 self.utRerunFailedAct.setEnabled(False) |
5403 self.rerunFailedTestsAct.setEnabled(False) |
5405 |
5404 |
5406 def __unittestRestart(self): |
5405 def __restartTest(self): |
5407 """ |
5406 """ |
5408 Private slot to display the unittest dialog and rerun the last |
5407 Private slot to display the testing dialog and rerun the last |
5409 unit test. |
5408 test run. |
5410 """ |
5409 """ |
5411 self.__unittest() |
5410 self.__startTesting() |
5412 self.__unittestWidget.startTests() |
5411 self.__testingWidget.startTests() |
5413 |
5412 |
5414 def __unittestRerunFailed(self): |
5413 def __rerunFailedTests(self): |
5415 """ |
5414 """ |
5416 Private slot to display the unittest dialog and rerun all failed tests |
5415 Private slot to display the testing dialog and rerun all failed tests |
5417 of the last run. |
5416 of the last run. |
5418 """ |
5417 """ |
5419 self.__unittest() |
5418 self.__startTesting() |
5420 self.__unittestWidget.startTests(failedOnly=True) |
5419 self.__testingWidget.startTests(failedOnly=True) |
5421 |
5420 |
5422 @pyqtSlot() |
5421 @pyqtSlot() |
5423 @pyqtSlot(str) |
5422 @pyqtSlot(str) |
5424 def __designer(self, fn=None): |
5423 def __designer(self, fn=None): |
5425 """ |
5424 """ |