eric7/Testing/TestingWidget.py

Mon, 23 May 2022 17:18:58 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 23 May 2022 17:18:58 +0200
branch
unittest
changeset 9093
437bfe0c5793
parent 9089
b48a6d0f6309
child 9192
a763d57e23bc
permissions
-rw-r--r--

Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).

9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de>
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a widget to orchestrate unit test execution.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
10 import contextlib
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import enum
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
12 import locale
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import os
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
15 from PyQt6.QtCore import pyqtSignal, pyqtSlot, Qt, QEvent, QCoreApplication
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from PyQt6.QtWidgets import (
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 QAbstractButton, QComboBox, QDialogButtonBox, QWidget
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 )
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 from EricWidgets import EricMessageBox
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 from EricWidgets.EricApplication import ericApp
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 from EricWidgets.EricMainWindow import EricMainWindow
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 from EricWidgets.EricPathPicker import EricPathPickerModes
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
25 from .Ui_TestingWidget import Ui_TestingWidget
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
27 from .TestResultsTree import TestResultsModel, TestResultsTreeView
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 from .Interfaces import Frameworks
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
29 from .Interfaces.TestExecutorBase import (
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
30 TestConfig, TestResult, TestResultCategory
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
31 )
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
32 from .Interfaces.TestFrameworkRegistry import TestFrameworkRegistry
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 import Preferences
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 import UI.PixmapCache
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 from Globals import (
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
38 recentNameTestDiscoverHistory, recentNameTestFileHistory,
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
39 recentNameTestNameHistory, recentNameTestFramework,
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
40 recentNameTestEnvironment
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 )
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
44 class TestingWidgetModes(enum.Enum):
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
46 Class defining the various modes of the testing widget.
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 IDLE = 0 # idle, no test were run yet
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 RUNNING = 1 # test run being performed
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 STOPPED = 2 # test run finished
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
53 class TestingWidget(QWidget, Ui_TestingWidget):
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 Class implementing a widget to orchestrate unit test execution.
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
56
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
57 @signal testFile(str, int, bool) emitted to show the source of a
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
58 test file
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
59 @signal testRunStopped() emitted after a test run has finished
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
61 testFile = pyqtSignal(str, int, bool)
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
62 testRunStopped = pyqtSignal()
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
63
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 def __init__(self, testfile=None, parent=None):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 Constructor
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 @param testfile file name of the test to load
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 @type str
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 @param parent reference to the parent widget (defaults to None)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 @type QWidget (optional)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 super().__init__(parent)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.setupUi(self)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__resultsModel = TestResultsModel(self)
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
77 self.__resultsModel.summary.connect(self.__setStatusLabel)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.__resultsTree = TestResultsTreeView(self)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.__resultsTree.setModel(self.__resultsModel)
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
80 self.__resultsTree.goto.connect(self.__showSource)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.resultsGroupBox.layout().addWidget(self.__resultsTree)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.versionsButton.setIcon(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 UI.PixmapCache.getIcon("info"))
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.clearHistoriesButton.setIcon(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 UI.PixmapCache.getIcon("clearPrivateData"))
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.testsuitePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.testsuitePicker.setInsertPolicy(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 QComboBox.InsertPolicy.InsertAtTop)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.testsuitePicker.setSizeAdjustPolicy(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.discoveryPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.discoveryPicker.setInsertPolicy(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 QComboBox.InsertPolicy.InsertAtTop)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.discoveryPicker.setSizeAdjustPolicy(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.testComboBox.lineEdit().setClearButtonEnabled(True)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 # create some more dialog buttons for orchestration
9093
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
103 self.__showLogButton = self.buttonBox.addButton(
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
104 self.tr("Show Output..."),
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
105 QDialogButtonBox.ButtonRole.ActionRole)
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
106 self.__showLogButton.setToolTip(
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
107 self.tr("Show the output of the test runner process"))
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
108 self.__showLogButton.setWhatsThis(self.tr(
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
109 """<b>Show Output...</b"""
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
110 """<p>This button opens a dialog containing the output of the"""
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
111 """ test runner process of the most recent run.</p>"""))
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
112
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
113 self.__showCoverageButton = self.buttonBox.addButton(
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
114 self.tr("Show Coverage..."),
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
115 QDialogButtonBox.ButtonRole.ActionRole)
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
116 self.__showCoverageButton.setToolTip(
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
117 self.tr("Show code coverage in a new dialog"))
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
118 self.__showCoverageButton.setWhatsThis(self.tr(
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
119 """<b>Show Coverage...</b>"""
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
120 """<p>This button opens a dialog containing the collected code"""
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
121 """ coverage data.</p>"""))
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
122
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.__startButton = self.buttonBox.addButton(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 self.tr("Start"), QDialogButtonBox.ButtonRole.ActionRole)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self.__startButton.setToolTip(self.tr(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 "Start the selected testsuite"))
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 self.__startButton.setWhatsThis(self.tr(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """<b>Start Test</b>"""
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
130 """<p>This button starts the test run.</p>"""))
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
132 self.__startFailedButton = self.buttonBox.addButton(
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
133 self.tr("Rerun Failed"), QDialogButtonBox.ButtonRole.ActionRole)
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
134 self.__startFailedButton.setToolTip(
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
135 self.tr("Reruns failed tests of the selected testsuite"))
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
136 self.__startFailedButton.setWhatsThis(self.tr(
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
137 """<b>Rerun Failed</b>"""
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
138 """<p>This button reruns all failed tests of the most recent"""
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
139 """ test run.</p>"""))
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
140
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 self.__stopButton = self.buttonBox.addButton(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 self.tr("Stop"), QDialogButtonBox.ButtonRole.ActionRole)
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
143 self.__stopButton.setToolTip(self.tr("Stop the running test"))
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 self.__stopButton.setWhatsThis(self.tr(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 """<b>Stop Test</b>"""
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
146 """<p>This button stops a running test.</p>"""))
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 self.setWindowFlags(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.windowFlags() |
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 Qt.WindowType.WindowContextHelpButtonHint
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 )
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 self.setWindowIcon(UI.PixmapCache.getIcon("eric"))
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
153 self.setWindowTitle(self.tr("Testing"))
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
155 try:
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
156 # we are called from within the eric IDE
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
157 self.__venvManager = ericApp().getObject("VirtualEnvManager")
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
158 self.__project = ericApp().getObject("Project")
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
159 self.__project.projectOpened.connect(self.__projectOpened)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
160 self.__project.projectClosed.connect(self.__projectClosed)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
161 except KeyError:
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
162 # we were called as a standalone application
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
163 from VirtualEnv.VirtualenvManager import VirtualenvManager
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
164 self.__venvManager = VirtualenvManager(self)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
165 self.__venvManager.virtualEnvironmentAdded.connect(
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
166 self.__populateVenvComboBox)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
167 self.__venvManager.virtualEnvironmentRemoved.connect(
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
168 self.__populateVenvComboBox)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
169 self.__venvManager.virtualEnvironmentChanged.connect(
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
170 self.__populateVenvComboBox)
9089
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
171 ericApp().registerObject("VirtualEnvManager", self.__venvManager)
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
172
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
173 self.__project = None
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 self.__discoverHistory = []
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 self.__fileHistory = []
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 self.__testNameHistory = []
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 self.__recentFramework = ""
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 self.__recentEnvironment = ""
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
180 self.__failedTests = []
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
182 self.__coverageFile = ""
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
183 self.__coverageDialog = None
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
184
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 self.__editors = []
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.__testExecutor = None
9093
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
187 self.__recentLog = ""
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 # connect some signals
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 self.discoveryPicker.editTextChanged.connect(
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
191 self.__resetResults)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 self.testsuitePicker.editTextChanged.connect(
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
193 self.__resetResults)
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
194 self.testComboBox.editTextChanged.connect(
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
195 self.__resetResults)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
197 self.__frameworkRegistry = TestFrameworkRegistry()
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 for framework in Frameworks:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 self.__frameworkRegistry.register(framework)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 self.__setIdleMode()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 self.__loadRecent()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.__populateVenvComboBox()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
206 if self.__project and self.__project.isOpen():
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
207 self.venvComboBox.setCurrentText(self.__project.getProjectVenv())
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
208 self.frameworkComboBox.setCurrentText(
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
209 self.__project.getProjectTestingFramework())
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
210 self.__insertDiscovery(self.__project.getProjectPath())
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 else:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 self.__insertDiscovery("")
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
213
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
214 self.__insertTestFile(testfile)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.__insertTestName("")
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 self.clearHistoriesButton.clicked.connect(self.clearRecent)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 self.tabWidget.setCurrentIndex(0)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 def __populateVenvComboBox(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 Private method to (re-)populate the virtual environments selector.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 currentText = self.venvComboBox.currentText()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 if not currentText:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 currentText = self.__recentEnvironment
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 self.venvComboBox.clear()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 self.venvComboBox.addItem("")
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 self.venvComboBox.addItems(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 sorted(self.__venvManager.getVirtualenvNames()))
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
233 self.venvComboBox.setCurrentText(currentText)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 def __populateTestFrameworkComboBox(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 Private method to (re-)populate the test framework selector.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 currentText = self.frameworkComboBox.currentText()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 if not currentText:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 currentText = self.__recentFramework
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 self.frameworkComboBox.clear()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 if bool(self.venvComboBox.currentText()):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 interpreter = self.__venvManager.getVirtualenvInterpreter(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 self.venvComboBox.currentText())
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 self.frameworkComboBox.addItem("")
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 for index, (name, executor) in enumerate(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 sorted(self.__frameworkRegistry.getFrameworks().items()),
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 start=1
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 ):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 isInstalled = executor.isInstalled(interpreter)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 entry = (
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 name
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 if isInstalled else
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 self.tr("{0} (not available)").format(name)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 )
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 self.frameworkComboBox.addItem(entry)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 self.frameworkComboBox.model().item(index).setEnabled(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 isInstalled)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 self.frameworkComboBox.setCurrentText(self.__recentFramework)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
265 def getResultsModel(self):
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
266 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
267 Public method to get a reference to the model containing the test
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
268 result data.
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
269
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
270 @return reference to the test results model
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
271 @rtype TestResultsModel
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
272 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
273 return self.__resultsModel
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
274
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
275 def hasFailedTests(self):
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
276 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
277 Public method to check for failed tests.
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
278
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
279 @return flag indicating the existence of failed tests
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
280 @rtype bool
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
281 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
282 return bool(self.__resultsModel.getFailedTests())
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
283
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
284 def getFailedTests(self):
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
285 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
286 Public method to get the list of failed tests (if any).
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
287
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
288 @return list of IDs of failed tests
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
289 @rtype list of str
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
290 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
291 return self.__failedTests[:]
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
292
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 @pyqtSlot(str)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 def __insertHistory(self, widget, history, item):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 Private slot to insert an item into a history object.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 @param widget reference to the widget
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 @type QComboBox or EricComboPathPicker
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 @param history array containing the history
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 @type list of str
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 @param item item to be inserted
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 @type str
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 # prepend the given directory to the discovery picker
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 if item is None:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 item = ""
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 if item in history:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 history.remove(item)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 history.insert(0, item)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 widget.clear()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 widget.addItems(history)
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
313 widget.setEditText(item)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 @pyqtSlot(str)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 def __insertDiscovery(self, start):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 Private slot to insert the discovery start directory into the
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 discoveryPicker object.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 @param start start directory name to be inserted
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 @type str
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 self.__insertHistory(self.discoveryPicker, self.__discoverHistory,
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 start)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 @pyqtSlot(str)
9072
8d3ae97ee666 Modified the 'getTestFileName()' function of the Utilities module to allow for additional test file name patterns (currently 'test...' and 'test_...').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9070
diff changeset
328 def setTestFile(self, testFile, forProject=False):
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
329 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
330 Public slot to set the given test file as the current one.
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
331
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
332 @param testFile path of the test file
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
333 @type str
9072
8d3ae97ee666 Modified the 'getTestFileName()' function of the Utilities module to allow for additional test file name patterns (currently 'test...' and 'test_...').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9070
diff changeset
334 @param forProject flag indicating that this call is for a project
8d3ae97ee666 Modified the 'getTestFileName()' function of the Utilities module to allow for additional test file name patterns (currently 'test...' and 'test_...').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9070
diff changeset
335 (defaults to False)
8d3ae97ee666 Modified the 'getTestFileName()' function of the Utilities module to allow for additional test file name patterns (currently 'test...' and 'test_...').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9070
diff changeset
336 @type bool (optional)
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
337 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
338 if testFile:
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
339 self.__insertTestFile(testFile)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
340
9072
8d3ae97ee666 Modified the 'getTestFileName()' function of the Utilities module to allow for additional test file name patterns (currently 'test...' and 'test_...').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9070
diff changeset
341 self.discoverCheckBox.setChecked(forProject or not bool(testFile))
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
342
9089
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
343 if forProject:
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
344 self.__projectOpened()
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
345
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
346 self.tabWidget.setCurrentIndex(0)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
347
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
348 @pyqtSlot(str)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
349 def __insertTestFile(self, prog):
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 Private slot to insert a test file name into the testsuitePicker
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 object.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 @param prog test file name to be inserted
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 @type str
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 self.__insertHistory(self.testsuitePicker, self.__fileHistory,
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 prog)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 @pyqtSlot(str)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 def __insertTestName(self, testName):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 Private slot to insert a test name into the testComboBox object.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 @param testName name of the test to be inserted
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 @type str
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 self.__insertHistory(self.testComboBox, self.__testNameHistory,
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 testName)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 def __loadRecent(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 Private method to load the most recently used lists.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 Preferences.Prefs.rsettings.sync()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 # 1. recently selected test framework and virtual environment
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 self.__recentEnvironment = Preferences.Prefs.rsettings.value(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
379 recentNameTestEnvironment, "")
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 self.__recentFramework = Preferences.Prefs.rsettings.value(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
381 recentNameTestFramework, "")
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 # 2. discovery history
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 self.__discoverHistory = []
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 rs = Preferences.Prefs.rsettings.value(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
386 recentNameTestDiscoverHistory)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 if rs is not None:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 recent = [f for f in Preferences.toList(rs) if os.path.exists(f)]
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 self.__discoverHistory = recent[
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 :Preferences.getDebugger("RecentNumber")]
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 # 3. test file history
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 self.__fileHistory = []
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 rs = Preferences.Prefs.rsettings.value(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
395 recentNameTestFileHistory)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 if rs is not None:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 recent = [f for f in Preferences.toList(rs) if os.path.exists(f)]
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 self.__fileHistory = recent[
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 :Preferences.getDebugger("RecentNumber")]
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 # 4. test name history
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 self.__testNameHistory = []
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 rs = Preferences.Prefs.rsettings.value(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
404 recentNameTestNameHistory)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 if rs is not None:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 recent = [n for n in Preferences.toList(rs) if n]
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 self.__testNameHistory = recent[
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 :Preferences.getDebugger("RecentNumber")]
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 def __saveRecent(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 Private method to save the most recently used lists.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 Preferences.Prefs.rsettings.setValue(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
415 recentNameTestEnvironment, self.__recentEnvironment)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 Preferences.Prefs.rsettings.setValue(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
417 recentNameTestFramework, self.__recentFramework)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 Preferences.Prefs.rsettings.setValue(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
419 recentNameTestDiscoverHistory, self.__discoverHistory)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 Preferences.Prefs.rsettings.setValue(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
421 recentNameTestFileHistory, self.__fileHistory)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 Preferences.Prefs.rsettings.setValue(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
423 recentNameTestNameHistory, self.__testNameHistory)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 Preferences.Prefs.rsettings.sync()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 @pyqtSlot()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 def clearRecent(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 Public slot to clear the recently used lists.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 # clear histories
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 self.__discoverHistory = []
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 self.__fileHistory = []
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 self.__testNameHistory = []
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 # clear widgets with histories
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 self.discoveryPicker.clear()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 self.testsuitePicker.clear()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 self.testComboBox.clear()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 # sync histories
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 self.__saveRecent()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
445 @pyqtSlot()
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
446 def __resetResults(self):
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
447 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
448 Private slot to reset the test results tab and data.
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
449 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
450 self.__totalCount = 0
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
451 self.__runCount = 0
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
452
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
453 self.progressCounterRunCount.setText("0")
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
454 self.progressCounterRemCount.setText("0")
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
455 self.progressProgressBar.setMaximum(100)
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
456 self.progressProgressBar.setValue(0)
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
457
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
458 self.statusLabel.clear()
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
459
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
460 self.__resultsModel.clear()
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
461 self.__updateButtonBoxButtons()
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
462
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
463 @pyqtSlot()
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 def __updateButtonBoxButtons(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 """
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
466 Private slot to update the state of the buttons of the button box.
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 """
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
468 failedAvailable = bool(self.__resultsModel.getFailedTests())
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 # Start button
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 if self.__mode in (
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
472 TestingWidgetModes.IDLE, TestingWidgetModes.STOPPED
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 ):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 self.__startButton.setEnabled(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 bool(self.venvComboBox.currentText()) and
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 bool(self.frameworkComboBox.currentText()) and
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 (
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 (self.discoverCheckBox.isChecked() and
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 bool(self.discoveryPicker.currentText())) or
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 bool(self.testsuitePicker.currentText())
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 )
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 )
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 self.__startButton.setDefault(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
484 self.__mode == TestingWidgetModes.IDLE or
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 not failedAvailable
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 )
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 else:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 self.__startButton.setEnabled(False)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 self.__startButton.setDefault(False)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 # Start Failed button
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
492 self.__startFailedButton.setEnabled(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
493 self.__mode == TestingWidgetModes.STOPPED and
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
494 failedAvailable
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
495 )
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
496 self.__startFailedButton.setDefault(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
497 self.__mode == TestingWidgetModes.STOPPED and
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
498 failedAvailable
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
499 )
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 # Stop button
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 self.__stopButton.setEnabled(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
503 self.__mode == TestingWidgetModes.RUNNING)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 self.__stopButton.setDefault(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
505 self.__mode == TestingWidgetModes.RUNNING)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
506
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
507 # Code coverage button
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
508 self.__showCoverageButton.setEnabled(
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
509 self.__mode == TestingWidgetModes.STOPPED and
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
510 bool(self.__coverageFile) and
9089
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
511 (
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
512 (self.discoverCheckBox.isChecked() and
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
513 bool(self.discoveryPicker.currentText())) or
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
514 bool(self.testsuitePicker.currentText())
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
515 )
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
516 )
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
517
9093
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
518 # Log output button
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
519 self.__showLogButton.setEnabled(bool(self.__recentLog))
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
520
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
521 # Close button
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
522 self.buttonBox.button(
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
523 QDialogButtonBox.StandardButton.Close
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
524 ).setEnabled(self.__mode in (
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
525 TestingWidgetModes.IDLE, TestingWidgetModes.STOPPED
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
526 ))
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
527
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
528 @pyqtSlot()
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
529 def __updateProgress(self):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
530 """
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
531 Private slot update the progress indicators.
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
532 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
533 self.progressCounterRunCount.setText(
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
534 str(self.__runCount))
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
535 self.progressCounterRemCount.setText(
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
536 str(self.__totalCount - self.__runCount))
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
537 self.progressProgressBar.setMaximum(self.__totalCount)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
538 self.progressProgressBar.setValue(self.__runCount)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
540 @pyqtSlot()
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 def __setIdleMode(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 """
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
543 Private slot to switch the widget to idle mode.
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 """
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
545 self.__mode = TestingWidgetModes.IDLE
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 self.__updateButtonBoxButtons()
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
547 self.progressGroupBox.hide()
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
548 self.tabWidget.setCurrentIndex(0)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
550 @pyqtSlot()
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 def __setRunningMode(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 """
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
553 Private slot to switch the widget to running mode.
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 """
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
555 self.__mode = TestingWidgetModes.RUNNING
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
556
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
557 self.__totalCount = 0
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
558 self.__runCount = 0
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
559
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
560 self.__coverageFile = ""
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
561
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
562 self.sbLabel.setText(self.tr("Running"))
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
563 self.tabWidget.setCurrentIndex(1)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
564 self.__updateButtonBoxButtons()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
565 self.__updateProgress()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
566
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
567 self.progressGroupBox.show()
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
569 @pyqtSlot()
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 def __setStoppedMode(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 """
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
572 Private slot to switch the widget to stopped mode.
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 """
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
574 self.__mode = TestingWidgetModes.STOPPED
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
575 if self.__totalCount == 0:
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
576 self.progressProgressBar.setMaximum(100)
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
577
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
578 self.progressGroupBox.hide()
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
579
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
580 self.__updateButtonBoxButtons()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
581
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
582 self.testRunStopped.emit()
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
583
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
584 self.raise_()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
585 self.activateWindow()
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
587 @pyqtSlot(bool)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
588 def on_discoverCheckBox_toggled(self, checked):
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
589 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
590 Private slot handling state changes of the 'discover' checkbox.
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
591
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
592 @param checked state of the checkbox
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
593 @type bool
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
594 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
595 if not bool(self.discoveryPicker.currentText()):
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
596 if self.__project and self.__project.isOpen():
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
597 self.__insertDiscovery(self.__project.getProjectPath())
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
598 else:
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
599 self.__insertDiscovery(
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
600 Preferences.getMultiProject("Workspace"))
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
601
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
602 self.__resetResults()
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
603
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
604 @pyqtSlot()
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
605 def on_testsuitePicker_aboutToShowPathPickerDialog(self):
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
606 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
607 Private slot called before the test file selection dialog is shown.
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
608 """
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
609 if self.__project:
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
610 # we were called from within eric
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
611 py3Extensions = ' '.join([
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
612 "*{0}".format(ext)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
613 for ext in
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
614 ericApp().getObject("DebugServer").getExtensions('Python3')
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
615 ])
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
616 fileFilter = self.tr(
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
617 "Python3 Files ({0});;All Files (*)"
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
618 ).format(py3Extensions)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
619 else:
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
620 # standalone application
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
621 fileFilter = self.tr("Python Files (*.py);;All Files (*)")
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
622 self.testsuitePicker.setFilters(fileFilter)
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
623
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
624 defaultDirectory = (
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
625 self.__project.getProjectPath()
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
626 if self.__project and self.__project.isOpen() else
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
627 Preferences.getMultiProject("Workspace")
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
628 )
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
629 if not defaultDirectory:
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
630 defaultDirectory = os.path.expanduser("~")
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
631 self.testsuitePicker.setDefaultDirectory(defaultDirectory)
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
632
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 @pyqtSlot(QAbstractButton)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 def on_buttonBox_clicked(self, button):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 Private slot called by a button of the button box clicked.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 @param button button that was clicked
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 @type QAbstractButton
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
641 if button == self.__startButton:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642 self.startTests()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643 self.__saveRecent()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 elif button == self.__stopButton:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 self.__stopTests()
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
646 elif button == self.__startFailedButton:
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
647 self.startTests(failedOnly=True)
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
648 elif button == self.__showCoverageButton:
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
649 self.__showCoverageDialog()
9093
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
650 elif button == self.__showLogButton:
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
651 self.__showLogOutput()
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 @pyqtSlot(int)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 def on_venvComboBox_currentIndexChanged(self, index):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 Private slot handling the selection of a virtual environment.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 @param index index of the selected environment
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 @type int
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 self.__populateTestFrameworkComboBox()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 self.__updateButtonBoxButtons()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664 self.versionsButton.setEnabled(bool(self.venvComboBox.currentText()))
9089
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
665
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
666 self.__updateCoverage()
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
667
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
668 @pyqtSlot(int)
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
669 def on_frameworkComboBox_currentIndexChanged(self, index):
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
670 """
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
671 Private slot handling the selection of a test framework.
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
672
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
673 @param index index of the selected framework
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
674 @type int
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
675 """
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
676 self.__resetResults()
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
677 self.__updateCoverage()
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
678
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
679 @pyqtSlot()
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
680 def __updateCoverage(self):
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
681 """
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
682 Private slot to update the state of the coverage checkbox depending on
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
683 the selected framework's capabilities.
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
684 """
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
685 hasCoverage = False
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
686
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
687 venvName = self.venvComboBox.currentText()
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
688 if venvName:
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
689 framework = self.frameworkComboBox.currentText()
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
690 if framework:
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
691 interpreter = self.__venvManager.getVirtualenvInterpreter(
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
692 venvName)
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
693 executor = self.__frameworkRegistry.createExecutor(
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
694 framework, self)
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
695 hasCoverage = executor.hasCoverage(interpreter)
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
696
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
697 self.coverageCheckBox.setEnabled(hasCoverage)
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
698 if not hasCoverage:
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
699 self.coverageCheckBox.setChecked(False)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
700
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
701 @pyqtSlot()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
702 def on_versionsButton_clicked(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
704 Private slot to show the versions of available plugins.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
705 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706 venvName = self.venvComboBox.currentText()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
707 if venvName:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
708 headerText = self.tr("<h3>Versions of Frameworks and their"
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
709 " Plugins</h3>")
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
710 versionsText = ""
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711 interpreter = self.__venvManager.getVirtualenvInterpreter(venvName)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
712 for framework in sorted(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713 self.__frameworkRegistry.getFrameworks().keys()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 ):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 executor = self.__frameworkRegistry.createExecutor(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 framework, self)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
717 versions = executor.getVersions(interpreter)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 if versions:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719 txt = "<p><strong>{0} {1}</strong>".format(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
720 versions["name"], versions["version"])
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
721
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
722 if versions["plugins"]:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723 txt += "<table>"
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
724 for pluginVersion in versions["plugins"]:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725 txt += self.tr(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726 "<tr><td>{0}</td><td>{1}</td></tr>"
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727 ).format(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 pluginVersion["name"], pluginVersion["version"]
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729 )
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730 txt += "</table>"
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
731 txt += "</p>"
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733 versionsText += txt
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 if not versionsText:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 versionsText = self.tr("No version information available.")
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 EricMessageBox.information(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739 self,
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
740 self.tr("Versions"),
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 headerText + versionsText
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 )
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
743
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
744 @pyqtSlot()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
745 def startTests(self, failedOnly=False):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 Public slot to start the test run.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749 @param failedOnly flag indicating to run only failed tests
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 @type bool
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 """
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
752 if self.__mode == TestingWidgetModes.RUNNING:
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753 return
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754
9093
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
755 self.__recentLog = ""
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
756
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757 self.__recentEnvironment = self.venvComboBox.currentText()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758 self.__recentFramework = self.frameworkComboBox.currentText()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
760 self.__failedTests = (
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
761 self.__resultsModel.getFailedTests()
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
762 if failedOnly else
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
763 []
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
764 )
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765 discover = self.discoverCheckBox.isChecked()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 if discover:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767 discoveryStart = self.discoveryPicker.currentText()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 testFileName = ""
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
769 testName = ""
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
770
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
771 if discoveryStart:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772 self.__insertDiscovery(discoveryStart)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773 else:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
774 discoveryStart = ""
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 testFileName = self.testsuitePicker.currentText()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776 if testFileName:
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
777 self.__insertTestFile(testFileName)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 testName = self.testComboBox.currentText()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779 if testName:
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
780 self.__insertTestName(testName)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
782 self.sbLabel.setText(self.tr("Preparing Testsuite"))
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
783 QCoreApplication.processEvents()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
784
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
785 if self.__project:
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
786 mainScript = self.__project.getMainScript(True)
9084
ee36935f4edd Corrected some little issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9081
diff changeset
787 coverageFile = (
ee36935f4edd Corrected some little issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9081
diff changeset
788 os.path.splitext(mainScript)[0] + ".coverage"
ee36935f4edd Corrected some little issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9081
diff changeset
789 if mainScript else
ee36935f4edd Corrected some little issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9081
diff changeset
790 ""
ee36935f4edd Corrected some little issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9081
diff changeset
791 )
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
792 else:
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
793 coverageFile = ""
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 interpreter = self.__venvManager.getVirtualenvInterpreter(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795 self.__recentEnvironment)
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
796 config = TestConfig(
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797 interpreter=interpreter,
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
798 discover=discover,
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799 discoveryStart=discoveryStart,
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 testFilename=testFileName,
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 testName=testName,
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 failFast=self.failfastCheckBox.isChecked(),
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
803 failedOnly=failedOnly,
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 collectCoverage=self.coverageCheckBox.isChecked(),
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 eraseCoverage=self.coverageEraseCheckBox.isChecked(),
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
806 coverageFile=coverageFile,
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807 )
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 self.__testExecutor = self.__frameworkRegistry.createExecutor(
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 self.__recentFramework, self)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
811 self.__testExecutor.collected.connect(self.__testsCollected)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812 self.__testExecutor.collectError.connect(self.__testsCollectError)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
813 self.__testExecutor.startTest.connect(self.__testStarted)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 self.__testExecutor.testResult.connect(self.__processTestResult)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815 self.__testExecutor.testFinished.connect(self.__testProcessFinished)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
816 self.__testExecutor.testRunFinished.connect(self.__testRunFinished)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817 self.__testExecutor.stop.connect(self.__testsStopped)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
818 self.__testExecutor.coverageDataSaved.connect(self.__coverageData)
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
819 self.__testExecutor.testRunAboutToBeStarted.connect(
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
820 self.__testRunAboutToBeStarted)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
821
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
822 self.__setRunningMode()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
823 self.__testExecutor.start(config, [])
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
824
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
825 @pyqtSlot()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
826 def __stopTests(self):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
827 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
828 Private slot to stop the current test run.
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
829 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
830 self.__testExecutor.stopIfRunning()
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 @pyqtSlot(list)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
833 def __testsCollected(self, testNames):
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
834 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 Private slot handling the 'collected' signal of the executor.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
836
9089
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
837 @param testNames list of tuples containing the test id, the test name
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
838 and a description of collected tests
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
839 @type list of tuple of (str, str, str)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 """
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
841 testResults = [
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
842 TestResult(
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
843 category=TestResultCategory.PENDING,
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
844 status=self.tr("pending"),
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
845 name=name,
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
846 id=id,
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
847 message=desc,
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
848 ) for id, name, desc in testNames
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
849 ]
9089
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
850 self.__resultsModel.addTestResults(testResults)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
851
9089
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
852 self.__totalCount += len(testResults)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
853 self.__updateProgress()
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 @pyqtSlot(list)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 def __testsCollectError(self, errors):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 Private slot handling the 'collectError' signal of the executor.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860 @param errors list of tuples containing the test name and a description
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 of the error
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 @type list of tuple of (str, str)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 """
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
864 testResults = []
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
865
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
866 for testFile, error in errors:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
867 if testFile:
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
868 testResults.append(TestResult(
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
869 category=TestResultCategory.FAIL,
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
870 status=self.tr("Failure"),
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
871 name=testFile,
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
872 id=testFile,
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
873 message=self.tr("Collection Error"),
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
874 extra=error.splitlines()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
875 ))
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
876 else:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
877 EricMessageBox.critical(
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
878 self,
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
879 self.tr("Collection Error"),
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
880 self.tr(
9081
2bbbc95972bf Updated translations and corrected some typs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9072
diff changeset
881 "<p>There was an error while collecting tests."
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
882 "</p><p>{0}</p>"
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
883 ).format("<br/>".join(error.splitlines()))
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
884 )
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
885
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
886 if testResults:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
887 self.__resultsModel.addTestResults(testResults)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
888
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
889 @pyqtSlot(tuple)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
890 def __testStarted(self, test):
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
891 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
892 Private slot handling the 'startTest' signal of the executor.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
893
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
894 @param test tuple containing the id, name and short description of the
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
895 tests about to be run
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
896 @type tuple of (str, str, str)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
897 """
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
898 self.__resultsModel.updateTestResults([
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
899 TestResult(
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
900 category=TestResultCategory.RUNNING,
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
901 status=self.tr("running"),
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
902 id=test[0],
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
903 name=test[1],
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
904 message="" if test[2] is None else test[2],
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
905 )
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
906 ])
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
907
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
908 @pyqtSlot(TestResult)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
909 def __processTestResult(self, result):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
910 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
911 Private slot to handle the receipt of a test result object.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
912
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
913 @param result test result object
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
914 @type TestResult
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
915 """
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
916 if not result.subtestResult:
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
917 self.__runCount += 1
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
918 self.__updateProgress()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
919
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
920 self.__resultsModel.updateTestResults([result])
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
921
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922 @pyqtSlot(list, str)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
923 def __testProcessFinished(self, results, output):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
924 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
925 Private slot to handle the 'testFinished' signal of the executor.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
926
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927 @param results list of test result objects (if not sent via the
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
928 'testResult' signal
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
929 @type list of TestResult
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
930 @param output string containing the test process output (if any)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
931 @type str
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
932 """
9093
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
933 self.__recentLog = output
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
934
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
935 self.__setStoppedMode()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
936 self.__testExecutor = None
9089
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
937
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
938 self.__adjustPendingState()
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
939
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
940 @pyqtSlot(int, float)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
941 def __testRunFinished(self, noTests, duration):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
942 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
943 Private slot to handle the 'testRunFinished' signal of the executor.
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
944
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
945 @param noTests number of tests run by the executor
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
946 @type int
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
947 @param duration time needed in seconds to run the tests
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
948 @type float
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
949 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
950 self.sbLabel.setText(
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
951 self.tr("Ran %n test(s) in {0}s", "", noTests).format(
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
952 locale.format_string("%.3f", duration, grouping=True)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
953 )
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
954 )
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
955
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
956 self.__setStoppedMode()
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958 @pyqtSlot()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959 def __testsStopped(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
960 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
961 Private slot to handle the 'stop' signal of the executor.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
962 """
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
963 self.sbLabel.setText(self.tr("Ran %n test(s)", "", self.__runCount))
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
964
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
965 self.__setStoppedMode()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
966
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
967 @pyqtSlot()
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
968 def __testRunAboutToBeStarted(self):
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
969 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
970 Private slot to handle the 'testRunAboutToBeStarted' signal of the
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
971 executor.
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
972 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
973 self.__resultsModel.clear()
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
974
9089
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
975 def __adjustPendingState(self):
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
976 """
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
977 Private method to change the status indicator of all still pending
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
978 tests to "not run".
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
979 """
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
980 newResults = []
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
981 for result in self.__resultsModel.getTestResults():
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
982 if result.category == TestResultCategory.PENDING:
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
983 result.category = TestResultCategory.SKIP
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
984 result.status = self.tr("not run")
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
985 newResults.append(result)
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
986
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
987 if newResults:
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
988 self.__resultsModel.updateTestResults(newResults)
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
989
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
990 @pyqtSlot(str)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
991 def __coverageData(self, coverageFile):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
992 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
993 Private slot to handle the 'coverageData' signal of the executor.
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
994
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
995 @param coverageFile file containing the coverage data
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
996 @type str
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
997 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
998 self.__coverageFile = coverageFile
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
999
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1000 @pyqtSlot()
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1001 def __showCoverageDialog(self):
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1002 """
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1003 Private slot to show a code coverage dialog for the most recent test
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1004 run.
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1005 """
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1006 if self.__coverageDialog is None:
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1007 from DataViews.PyCoverageDialog import PyCoverageDialog
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1008 self.__coverageDialog = PyCoverageDialog(self)
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1009 self.__coverageDialog.openFile.connect(self.__openEditor)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
1010
9089
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
1011 testDir = (
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
1012 self.discoveryPicker.currentText()
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
1013 if self.discoverCheckBox.isChecked() else
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
1014 os.path.dirname(self.testsuitePicker.currentText())
b48a6d0f6309 Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9084
diff changeset
1015 )
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1016 if testDir:
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1017 self.__coverageDialog.show()
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1018 self.__coverageDialog.start(self.__coverageFile, testDir)
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
1019
9093
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
1020 @pyqtSlot()
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
1021 def __showLogOutput(self):
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
1022 """
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
1023 Private slot to show the output of the most recent test run.
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
1024 """
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
1025 from EricWidgets.EricPlainTextDialog import EricPlainTextDialog
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
1026 dlg = EricPlainTextDialog(
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
1027 title=self.tr("Test Run Output"),
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
1028 text=self.__recentLog
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
1029 )
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
1030 dlg.exec()
437bfe0c5793 Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9089
diff changeset
1031
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
1032 @pyqtSlot(str)
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
1033 def __setStatusLabel(self, statusText):
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
1034 """
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
1035 Private slot to set the status label to the text sent by the model.
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
1036
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
1037 @param statusText text to be shown
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
1038 @type str
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
1039 """
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
1040 self.statusLabel.setText(f"<b>{statusText}</b>")
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1041
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1042 @pyqtSlot()
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1043 def __projectOpened(self):
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1044 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1045 Private slot to handle a project being opened.
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1046 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1047 self.venvComboBox.setCurrentText(self.__project.getProjectVenv())
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1048 self.frameworkComboBox.setCurrentText(
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1049 self.__project.getProjectTestingFramework())
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1050 self.__insertDiscovery(self.__project.getProjectPath())
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1051
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1052 @pyqtSlot()
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1053 def __projectClosed(self):
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1054 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1055 Private slot to handle a project being closed.
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1056 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1057 self.venvComboBox.setCurrentText("")
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1058 self.frameworkComboBox.setCurrentText("")
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1059 self.__insertDiscovery("")
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1060
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1061 @pyqtSlot(str, int)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1062 def __showSource(self, filename, lineno):
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1063 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1064 Private slot to show the source of a traceback in an editor.
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1066 @param filename file name of the file to be shown
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1067 @type str
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1068 @param lineno line number to go to in the file
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1069 @type int
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1070 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1071 if self.__project:
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1072 # running as part of eric IDE
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
1073 self.testFile.emit(filename, lineno, True)
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1074 else:
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1075 self.__openEditor(filename, lineno)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1076
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1077 def __openEditor(self, filename, linenumber=1):
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1078 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1079 Private method to open an editor window for the given file.
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1080
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
1081 Note: This method opens an editor window when the testing dialog
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1082 is called as a standalone application.
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1083
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1084 @param filename path of the file to be opened
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1085 @type str
9070
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1086 @param linenumber line number to place the cursor at (defaults to 1)
eab09a1ab8ce Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9066
diff changeset
1087 @type int (optional)
9065
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1088 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1089 from QScintilla.MiniEditor import MiniEditor
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1090 editor = MiniEditor(filename, "Python3", self)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1091 editor.gotoLine(linenumber)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1092 editor.show()
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1093
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1094 self.__editors.append(editor)
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1095
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1096 def closeEvent(self, event):
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1097 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1098 Protected method to handle the close event.
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1099
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1100 @param event close event
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1101 @type QCloseEvent
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1102 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1103 event.accept()
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1104
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1105 for editor in self.__editors:
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1106 with contextlib.suppress(Exception):
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
1107 editor.close()
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1108
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1109
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
1110 class TestingWindow(EricMainWindow):
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1111 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1112 Main window class for the standalone dialog.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1113 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1114 def __init__(self, testfile=None, parent=None):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1115 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1116 Constructor
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1117
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1118 @param testfile file name of the test script to open
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1119 @type str
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1120 @param parent reference to the parent widget
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1121 @type QWidget
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1122 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1123 super().__init__(parent)
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
1124 self.__cw = TestingWidget(testfile=testfile, parent=self)
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1125 self.__cw.installEventFilter(self)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1126 size = self.__cw.size()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1127 self.setCentralWidget(self.__cw)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1128 self.resize(size)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1129
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1130 self.setStyle(Preferences.getUI("Style"),
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1131 Preferences.getUI("StyleSheet"))
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1132
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1133 self.__cw.buttonBox.accepted.connect(self.close)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1134 self.__cw.buttonBox.rejected.connect(self.close)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1135
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1136 def eventFilter(self, obj, event):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1137 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1138 Public method to filter events.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1139
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1140 @param obj reference to the object the event is meant for (QObject)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1141 @param event reference to the event object (QEvent)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1142 @return flag indicating, whether the event was handled (boolean)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1143 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1144 if event.type() == QEvent.Type.Close:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1145 QCoreApplication.exit(0)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1146 return True
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1147
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1148 return False
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1149
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1150
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1151 def clearSavedHistories(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1152 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1153 Function to clear the saved history lists.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1154 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1155 Preferences.Prefs.rsettings.setValue(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
1156 recentNameTestDiscoverHistory, [])
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1157 Preferences.Prefs.rsettings.setValue(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
1158 recentNameTestFileHistory, [])
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1159 Preferences.Prefs.rsettings.setValue(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
1160 recentNameTestNameHistory, [])
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1161
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1162 Preferences.Prefs.rsettings.sync()

eric ide

mercurial