eric7/UI/UserInterface.py

branch
unittest
changeset 9065
39405e6eba20
parent 9064
339bb8c8007d
child 9066
a219ade50f7c
equal deleted inserted replaced
9064:339bb8c8007d 9065:39405e6eba20
339 self.stderr = Redirector(True, self) 339 self.stderr = Redirector(True, self)
340 340
341 # set a few dialog members for non-modal dialogs created on demand 341 # set a few dialog members for non-modal dialogs created on demand
342 self.programsDialog = None 342 self.programsDialog = None
343 self.shortcutsDialog = None 343 self.shortcutsDialog = None
344 self.unittestDialog = None 344 self.__unittestWidget = None
345 self.findFileNameDialog = None 345 self.findFileNameDialog = None
346 self.diffDlg = None 346 self.diffDlg = None
347 self.compareDlg = None 347 self.compareDlg = None
348 self.findFilesDialog = None 348 self.findFilesDialog = None
349 self.replaceFilesDialog = None 349 self.replaceFilesDialog = None
2518 self.tr('&Unittest...'), 2518 self.tr('&Unittest...'),
2519 0, 0, self.utActGrp, 'unittest') 2519 0, 0, self.utActGrp, 'unittest')
2520 self.utDialogAct.setStatusTip(self.tr('Start unittest dialog')) 2520 self.utDialogAct.setStatusTip(self.tr('Start unittest dialog'))
2521 self.utDialogAct.setWhatsThis(self.tr( 2521 self.utDialogAct.setWhatsThis(self.tr(
2522 """<b>Unittest</b>""" 2522 """<b>Unittest</b>"""
2523 """<p>Perform unit tests. The dialog gives you the""" 2523 """<p>Perform unit tests. The dialog gives the"""
2524 """ ability to select and run a unittest suite.</p>""" 2524 """ ability to select and run a unittest suite or"""
2525 """auto discover them.</p>"""
2525 )) 2526 ))
2526 self.utDialogAct.triggered.connect(self.__unittest) 2527 self.utDialogAct.triggered.connect(self.__unittest)
2527 self.actions.append(self.utDialogAct) 2528 self.actions.append(self.utDialogAct)
2528 2529
2529 self.utRestartAct = EricAction( 2530 self.utRestartAct = EricAction(
5330 dlg = ToolGroupConfigurationDialog( 5331 dlg = ToolGroupConfigurationDialog(
5331 self.toolGroups, self.currentToolGroup, self) 5332 self.toolGroups, self.currentToolGroup, self)
5332 if dlg.exec() == QDialog.DialogCode.Accepted: 5333 if dlg.exec() == QDialog.DialogCode.Accepted:
5333 self.toolGroups, self.currentToolGroup = dlg.getToolGroups() 5334 self.toolGroups, self.currentToolGroup = dlg.getToolGroups()
5334 5335
5335 # TODO: adjust to new unit test framework (without debugger)
5336 def __createUnitTestDialog(self): 5336 def __createUnitTestDialog(self):
5337 """ 5337 """
5338 Private slot to generate the unit test dialog on demand. 5338 Private slot to generate the unit test dialog on demand.
5339 """ 5339 """
5340 if self.unittestDialog is None: 5340 if self.__unittestWidget is None:
5341 from PyUnit.UnittestDialog import UnittestDialog 5341 from Unittest.UnittestWidget import UnittestWidget
5342 self.unittestDialog = UnittestDialog( 5342 self.__unittestWidget = UnittestWidget()
5343 None, self.__debugServer, self) 5343 self.__unittestWidget.unittestFile.connect(
5344 self.unittestDialog.unittestFile.connect(
5345 self.viewmanager.setFileLine) 5344 self.viewmanager.setFileLine)
5346 self.unittestDialog.unittestStopped.connect(self.__unittestStopped) 5345 self.__unittestWidget.unittestStopped.connect(
5346 self.__unittestStopped)
5347 5347
5348 def __unittestStopped(self): 5348 def __unittestStopped(self):
5349 """ 5349 """
5350 Private slot to handle the end of a unit test run. 5350 Private slot to handle the end of a unit test run.
5351 """ 5351 """
5352 self.utRerunFailedAct.setEnabled(self.unittestDialog.hasFailedTests()) 5352 self.utRerunFailedAct.setEnabled(
5353 self.__unittestWidget.hasFailedTests())
5353 self.utRestartAct.setEnabled(True) 5354 self.utRestartAct.setEnabled(True)
5354 5355
5355 def __unittest(self): 5356 def __unittest(self):
5356 """ 5357 """
5357 Private slot for displaying the unittest dialog. 5358 Private slot for displaying the unittest dialog.
5358 """ 5359 """
5359 self.__createUnitTestDialog() 5360 self.__createUnitTestDialog()
5360 self.unittestDialog.show() 5361 self.__unittestWidget.show()
5361 self.unittestDialog.raise_() 5362 self.__unittestWidget.raise_()
5362 5363
5363 @pyqtSlot() 5364 @pyqtSlot()
5364 @pyqtSlot(str) 5365 @pyqtSlot(str)
5365 def __unittestScript(self, prog=None): 5366 def __unittestScript(self, testFile=None):
5366 """ 5367 """
5367 Private slot for displaying the unittest dialog and run the current 5368 Private slot for displaying the unittest dialog and run the current
5368 script. 5369 script.
5369 5370
5370 @param prog the python program to be opened 5371 @param testFile file containing the unit tests to be run
5371 """ 5372 @type str
5372 if prog is None: 5373 """
5374 if testFile is None:
5373 aw = self.viewmanager.activeWindow() 5375 aw = self.viewmanager.activeWindow()
5374 fn = aw.getFileName() 5376 fn = aw.getFileName()
5375 tfn = Utilities.getTestFileName(fn) 5377 tfn = Utilities.getTestFileName(fn)
5376 if os.path.exists(tfn): 5378 if os.path.exists(tfn):
5377 prog = tfn 5379 testFile = tfn
5378 else: 5380 else:
5379 prog = fn 5381 testFile = fn
5380 5382
5381 self.__unittest() 5383 self.__unittest()
5382 self.unittestDialog.setProjectMode(False) 5384 self.__unittestWidget.setTestFile(testFile)
5383 self.unittestDialog.insertProg(prog)
5384 self.utRestartAct.setEnabled(False) 5385 self.utRestartAct.setEnabled(False)
5385 self.utRerunFailedAct.setEnabled(False) 5386 self.utRerunFailedAct.setEnabled(False)
5386 5387
5388 @pyqtSlot()
5387 def __unittestProject(self): 5389 def __unittestProject(self):
5388 """ 5390 """
5389 Private slot for displaying the unittest dialog and run the current 5391 Private slot for displaying the unittest dialog and run the current
5390 project. 5392 project.
5391 """ 5393 """
5392 prog = None 5394 testFile = None
5393 fn = self.project.getMainScript(True) 5395 fn = self.project.getMainScript(True)
5394 if fn: 5396 if fn:
5395 tfn = Utilities.getTestFileName(fn) 5397 tfn = Utilities.getTestFileName(fn)
5396 if os.path.exists(tfn): 5398 if os.path.exists(tfn):
5397 prog = tfn 5399 testFile = tfn
5398 else:
5399 prog = fn
5400 5400
5401 self.__unittest() 5401 self.__unittest()
5402 self.unittestDialog.setProjectMode(True) 5402 self.__unittestWidget.setTestFile(testFile)
5403 self.unittestDialog.insertProg(prog)
5404 self.utRestartAct.setEnabled(False) 5403 self.utRestartAct.setEnabled(False)
5405 self.utRerunFailedAct.setEnabled(False) 5404 self.utRerunFailedAct.setEnabled(False)
5406 5405
5407 def __unittestRestart(self): 5406 def __unittestRestart(self):
5408 """ 5407 """
5409 Private slot to display the unittest dialog and rerun the last 5408 Private slot to display the unittest dialog and rerun the last
5410 unit test. 5409 unit test.
5411 """ 5410 """
5412 self.__unittest() 5411 self.__unittest()
5413 self.unittestDialog.startTests() 5412 self.__unittestWidget.startTests()
5414 5413
5415 def __unittestRerunFailed(self): 5414 def __unittestRerunFailed(self):
5416 """ 5415 """
5417 Private slot to display the unittest dialog and rerun all failed tests 5416 Private slot to display the unittest dialog and rerun all failed tests
5418 of the last run. 5417 of the last run.
5419 """ 5418 """
5420 self.__unittest() 5419 self.__unittest()
5421 self.unittestDialog.startTests(failedOnly=True) 5420 self.__unittestWidget.startTests(failedOnly=True)
5422 5421
5423 @pyqtSlot() 5422 @pyqtSlot()
5424 @pyqtSlot(str) 5423 @pyqtSlot(str)
5425 def __designer(self, fn=None): 5424 def __designer(self, fn=None):
5426 """ 5425 """
6834 if shell: 6833 if shell:
6835 # clear the shell histories 6834 # clear the shell histories
6836 self.shell.clearAllHistories() 6835 self.shell.clearAllHistories()
6837 if unittests: 6836 if unittests:
6838 # clear the unit test histories 6837 # clear the unit test histories
6839 if self.unittestDialog is None: 6838 if self.__unittestWidget is None:
6840 from PyUnit.UnittestDialog import clearSavedHistories 6839 from Unittest.UnittestWidget import clearSavedHistories
6841 clearSavedHistories() 6840 clearSavedHistories()
6842 else: 6841 else:
6843 self.unittestDialog.clearRecent() 6842 self.__unittestWidget.clearRecent()
6844 if vcs: 6843 if vcs:
6845 # clear the VCS related histories 6844 # clear the VCS related histories
6846 self.pluginManager.clearPluginsPrivateData("version_control") 6845 self.pluginManager.clearPluginsPrivateData("version_control")
6847 if plugins: 6846 if plugins:
6848 # clear private data of plug-ins not covered above 6847 # clear private data of plug-ins not covered above

eric ide

mercurial