src/eric7/Testing/TestResultsTree.py

Wed, 09 Nov 2022 15:05:06 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 09 Nov 2022 15:05:06 +0100
branch
eric7
changeset 9500
5771348ded12
parent 9473
3f23dbf37dbe
child 9502
6091145e189e
permissions
-rw-r--r--

Corrected some code style issues and changed some suppressed code style issues.

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 tree view and associated model to show the test result
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 data.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
11 import contextlib
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
12 import copy
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
13 import locale
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
14
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
15 from collections import Counter
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
16 from operator import attrgetter
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
17
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from PyQt6.QtCore import (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
19 QAbstractItemModel,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
20 QCoreApplication,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
21 QModelIndex,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
22 QPoint,
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
23 Qt,
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
24 pyqtSignal,
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
25 pyqtSlot,
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 )
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
27 from PyQt6.QtGui import QBrush, QColor
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
28 from PyQt6.QtWidgets import QMenu, QTreeView
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
30 from eric7 import Preferences
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
31 from eric7.EricWidgets.EricApplication import ericApp
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
32
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
33 from .Interfaces.TestExecutorBase import TestResultCategory
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
34
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
35 TopLevelId = 2**32 - 1
9059
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
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 class TestResultsModel(QAbstractItemModel):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 Class implementing the item model containing the test data.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
41
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
42 @signal summary(str) emitted whenever the model data changes. The element
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
43 is a summary of the test results of the model.
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
45
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
46 summary = pyqtSignal(str)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
47
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 Headers = [
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 QCoreApplication.translate("TestResultsModel", "Status"),
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 QCoreApplication.translate("TestResultsModel", "Name"),
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 QCoreApplication.translate("TestResultsModel", "Message"),
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
52 QCoreApplication.translate("TestResultsModel", "Duration [ms]"),
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 ]
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
54
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
55 StatusColumn = 0
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
56 NameColumn = 1
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
57 MessageColumn = 2
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
58 DurationColumn = 3
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
59
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 def __init__(self, parent=None):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
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 @param parent reference to the parent object (defaults to None)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @type QObject (optional)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 super().__init__(parent)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
68
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
69 if ericApp().usesDarkPalette():
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
70 self.__backgroundColors = {
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
71 TestResultCategory.RUNNING: None,
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
72 TestResultCategory.FAIL: QBrush(QColor("#880000")),
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
73 TestResultCategory.OK: QBrush(QColor("#005500")),
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
74 TestResultCategory.SKIP: QBrush(QColor("#3f3f3f")),
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
75 TestResultCategory.PENDING: QBrush(QColor("#004768")),
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
76 }
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
77 else:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
78 self.__backgroundColors = {
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
79 TestResultCategory.RUNNING: None,
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
80 TestResultCategory.FAIL: QBrush(QColor("#ff8080")),
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
81 TestResultCategory.OK: QBrush(QColor("#c1ffba")),
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
82 TestResultCategory.SKIP: QBrush(QColor("#c5c5c5")),
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
83 TestResultCategory.PENDING: QBrush(QColor("#6fbaff")),
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
84 }
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
85
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.__testResults = []
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
87
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
88 def index(self, row, column, parent=QModelIndex()):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
89 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
90 Public method to generate an index for the given row and column to
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
91 identify the item.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
92
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
93 @param row row for the index
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
94 @type int
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
95 @param column column for the index
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
96 @type int
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
97 @param parent index of the parent item (defaults to QModelIndex())
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
98 @type QModelIndex (optional)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
99 @return index for the item
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
100 @rtype QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
101 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
102 if not self.hasIndex(row, column, parent): # check bounds etc.
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
103 return QModelIndex()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
104
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
105 if not parent.isValid():
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
106 # top level item
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
107 return self.createIndex(row, column, TopLevelId)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
108 else:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
109 testResultIndex = parent.row()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
110 return self.createIndex(row, column, testResultIndex)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
111
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
112 def data(self, index, role):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
113 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
114 Public method to get the data for the various columns and roles.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
115
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
116 @param index index of the data to be returned
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
117 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
118 @param role role designating the data to return
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
119 @type Qt.ItemDataRole
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
120 @return requested data item
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
121 @rtype Any
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
122 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
123 if not index.isValid():
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
124 return None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
125
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
126 row = index.row()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
127 column = index.column()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
128 idx = index.internalId()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
129
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
130 if role == Qt.ItemDataRole.DisplayRole:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
131 if idx != TopLevelId:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
132 if bool(self.__testResults[idx].extra):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
133 return self.__testResults[idx].extra[index.row()]
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
134 else:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
135 return None
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
136 elif column == TestResultsModel.StatusColumn:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
137 return self.__testResults[row].status
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
138 elif column == TestResultsModel.NameColumn:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
139 return self.__testResults[row].name
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
140 elif column == TestResultsModel.MessageColumn:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
141 return self.__testResults[row].message
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
142 elif column == TestResultsModel.DurationColumn:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
143 duration = self.__testResults[row].duration
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
144 return (
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
145 ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
146 if duration is None
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
147 else locale.format_string("%.2f", duration, grouping=True)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
148 )
9500
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
149 elif (
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
150 role == Qt.ItemDataRole.ToolTipRole
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
151 and idx == TopLevelId
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
152 and column == TestResultsModel.NameColumn
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
153 ):
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
154 return self.__testResults[row].name
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
155 elif role == Qt.ItemDataRole.FontRole and idx != TopLevelId:
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
156 return Preferences.getEditorOtherFonts("MonospacedFont")
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
157 elif role == Qt.ItemDataRole.BackgroundRole and idx == TopLevelId:
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
158 testResult = self.__testResults[row]
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
159 with contextlib.suppress(KeyError):
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
160 return self.__backgroundColors[testResult.category]
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
161 elif (
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
162 role == Qt.ItemDataRole.TextAlignmentRole
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
163 and idx == TopLevelId and column == TestResultsModel.DurationColumn
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
164 ):
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
165 return Qt.AlignmentFlag.AlignRight.value
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
166 elif role == Qt.ItemDataRole.UserRole and idx == TopLevelId:
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
167 testresult = self.__testResults[row]
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
168 return (testresult.filename, testresult.lineno)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
169
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
170 return None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
171
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
172 def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole):
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 Public method to get the header string for the various sections.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
175
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 @param section section number
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 @type int
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 @param orientation orientation of the header
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 @type Qt.Orientation
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 @param role data role (defaults to Qt.ItemDataRole.DisplayRole)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 @type Qt.ItemDataRole (optional)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 @return header string of the section
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 @rtype str
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
186 orientation == Qt.Orientation.Horizontal
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
187 and role == Qt.ItemDataRole.DisplayRole
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 return TestResultsModel.Headers[section]
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 else:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 return None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
192
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
193 def parent(self, index):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
194 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
195 Public method to get the parent of the item pointed to by index.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
196
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
197 @param index index of the item
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
198 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
199 @return index of the parent item
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
200 @rtype QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
201 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
202 if not index.isValid():
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
203 return QModelIndex()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
204
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
205 idx = index.internalId()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
206 if idx == TopLevelId:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
207 return QModelIndex()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
208 else:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
209 return self.index(idx, 0)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
210
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 def rowCount(self, parent=QModelIndex()):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 Public method to get the number of row for a given parent index.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
214
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 @param parent index of the parent item (defaults to QModelIndex())
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 @type QModelIndex (optional)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 @return number of rows
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 @rtype int
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 if not parent.isValid():
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 return len(self.__testResults)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
222
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
223 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
224 parent.internalId() == TopLevelId
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
225 and parent.column() == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
226 and self.__testResults[parent.row()].extra is not None
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
227 ):
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 return len(self.__testResults[parent.row()].extra)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
229
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 return 0
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 def columnCount(self, parent=QModelIndex()):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 Public method to get the number of columns.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
235
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 @param parent index of the parent item (defaults to QModelIndex())
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 @type QModelIndex (optional)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 @return number of columns
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 @rtype int
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 if not parent.isValid():
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 return len(TestResultsModel.Headers)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 else:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 return 1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
245
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 def clear(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 Public method to clear the model data.
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 self.beginResetModel()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 self.__testResults.clear()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 self.endResetModel()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
253
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
254 self.summary.emit("")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
255
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
256 def sort(self, column, order):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
257 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
258 Public method to sort the model data by column in order.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
259
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
260 @param column sort column number
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
261 @type int
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
262 @param order sort order
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
263 @type Qt.SortOrder
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
264 """ # __IGNORE_WARNING_D234r__
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
265
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
266 def durationKey(result):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
267 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
268 Function to generate a key for duration sorting
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
269
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
270 @param result 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
271 @type TestResult
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
272 @return sort key
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
273 @rtype float
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
274 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
275 return result.duration or -1.0
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
276
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
277 self.beginResetModel()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
278 reverse = order == Qt.SortOrder.DescendingOrder
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
279 if column == TestResultsModel.StatusColumn:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
280 self.__testResults.sort(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
281 key=attrgetter("category", "status"), reverse=reverse
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
282 )
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
283 elif column == TestResultsModel.NameColumn:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
284 self.__testResults.sort(key=attrgetter("name"), reverse=reverse)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
285 elif column == TestResultsModel.MessageColumn:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
286 self.__testResults.sort(key=attrgetter("message"), reverse=reverse)
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
287 elif column == TestResultsModel.DurationColumn:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
288 self.__testResults.sort(key=durationKey, reverse=reverse)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
289 self.endResetModel()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
290
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
291 def getTestResults(self):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
292 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
293 Public method to get the list of test results managed by the model.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
294
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
295 @return list of test results managed by the model
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
296 @rtype list of TestResult
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
297 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
298 return copy.deepcopy(self.__testResults)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
299
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
300 def setTestResults(self, testResults):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
301 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
302 Public method to set the list of test results of the model.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
303
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
304 @param testResults test results to be managed by the model
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
305 @type list of TestResult
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
306 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
307 self.beginResetModel()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
308 self.__testResults = copy.deepcopy(testResults)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
309 self.endResetModel()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
310
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
311 self.summary.emit(self.__summary())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
312
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
313 def addTestResults(self, testResults):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
314 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
315 Public method to add test results to the ones already managed by the
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
316 model.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
317
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
318 @param testResults test results to be added to the model
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
319 @type list of TestResult
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
320 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
321 firstRow = len(self.__testResults)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
322 lastRow = firstRow + len(testResults) - 1
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
323 self.beginInsertRows(QModelIndex(), firstRow, lastRow)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
324 self.__testResults.extend(testResults)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
325 self.endInsertRows()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
326
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
327 self.summary.emit(self.__summary())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
328
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
329 def updateTestResults(self, testResults):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
330 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
331 Public method to update the data of managed test result items.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
332
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
333 @param testResults test results to be updated
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
334 @type list of TestResult
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
335 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
336 minIndex = None
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
337 maxIndex = None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
338
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
339 testResultsToBeAdded = []
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
340
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
341 for testResult in testResults:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
342 for (index, currentResult) in enumerate(self.__testResults):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
343 if currentResult.id == testResult.id:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
344 self.__testResults[index] = testResult
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
345 if minIndex is None:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
346 minIndex = index
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
347 maxIndex = index
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
348 else:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
349 minIndex = min(minIndex, index)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
350 maxIndex = max(maxIndex, index)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
351
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
352 break
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
353 else:
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
354 # Test result with given id was not found.
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
355 # Just add it to the list (could be a sub test)
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
356 testResultsToBeAdded.append(testResult)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
357
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
358 if minIndex is not None:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
359 self.dataChanged.emit(
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
360 self.index(minIndex, 0),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
361 self.index(maxIndex, len(TestResultsModel.Headers) - 1),
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
362 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
363
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
364 self.summary.emit(self.__summary())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
365
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
366 if testResultsToBeAdded:
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
367 self.addTestResults(testResultsToBeAdded)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
368
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
369 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
370 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
371 Public method to extract the test ids of all failed tests.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
372
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
373 @return test ids of all failed tests
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
374 @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
375 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
376 failedIds = [
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
377 res.id
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
378 for res in self.__testResults
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
379 if (res.category == TestResultCategory.FAIL and not res.subtestResult)
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
380 ]
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
381 return failedIds
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
382
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
383 def __summary(self):
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
384 """
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
385 Private method to generate a test results summary text.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
386
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
387 @return test results summary text
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
388 @rtype str
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
389 """
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
390 if len(self.__testResults) == 0:
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
391 return self.tr("No results to show")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
392
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
393 counts = Counter(res.category for res in self.__testResults)
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
394 if all(
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
395 counts[category] == 0
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
396 for category in (
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
397 TestResultCategory.FAIL,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
398 TestResultCategory.OK,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
399 TestResultCategory.SKIP,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
400 )
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
401 ):
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
402 return self.tr("Collected %n test(s)", "", len(self.__testResults))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
403
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
404 return self.tr(
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
405 "%n test(s)/subtest(s) total, {0} failed, {1} passed,"
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
406 " {2} skipped, {3} pending",
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
407 "",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
408 len(self.__testResults),
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
409 ).format(
9066
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
410 counts[TestResultCategory.FAIL],
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
411 counts[TestResultCategory.OK],
a219ade50f7c Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9065
diff changeset
412 counts[TestResultCategory.SKIP],
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
413 counts[TestResultCategory.PENDING],
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
414 )
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 class TestResultsTreeView(QTreeView):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 Class implementing a tree view to show the test result data.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
420
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 @signal goto(str, int) emitted to go to the position given by file name
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 and line number
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
424
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 goto = pyqtSignal(str, int)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
426
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 def __init__(self, parent=None):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
430
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 @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
432 @type QWidget (optional)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 super().__init__(parent)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
435
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 self.setItemsExpandable(True)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 self.setExpandsOnDoubleClick(False)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 self.setSortingEnabled(True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
439
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 self.header().setDefaultAlignment(Qt.AlignmentFlag.AlignCenter)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 self.header().setSortIndicatorShown(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
442
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
443 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
444
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 # connect signals and slots
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 self.doubleClicked.connect(self.__gotoTestDefinition)
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
447 self.customContextMenuRequested.connect(self.__showContextMenu)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
448
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 self.header().sortIndicatorChanged.connect(self.sortByColumn)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 self.header().sortIndicatorChanged.connect(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
451 lambda column, order: self.header().setSortIndicatorShown(True)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
452 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
453
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
454 def reset(self):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
455 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
456 Public method to reset the internal state of the view.
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
457 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
458 super().reset()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
459
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
460 self.resizeColumns()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
461 self.spanFirstColumn(0, self.model().rowCount() - 1)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
462
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
463 def rowsInserted(self, parent, startRow, endRow):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
464 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
465 Public method called when rows are inserted.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
466
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
467 @param parent model index of the parent item
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
468 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
469 @param startRow first row been inserted
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
470 @type int
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
471 @param endRow last row been inserted
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
472 @type int
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
473 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
474 super().rowsInserted(parent, startRow, endRow)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
475
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
476 self.resizeColumns()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
477 self.spanFirstColumn(startRow, endRow)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
478
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
479 def dataChanged(self, topLeft, bottomRight, roles=[]):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
480 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
481 Public method called when the model data has changed.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
482
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
483 @param topLeft index of the top left element
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
484 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
485 @param bottomRight index of the bottom right element
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
486 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
487 @param roles list of roles changed (defaults to [])
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
488 @type list of Qt.ItemDataRole (optional)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
489 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
490 super().dataChanged(topLeft, bottomRight, roles)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
491
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
492 self.resizeColumns()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
493 while topLeft.parent().isValid():
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
494 topLeft = topLeft.parent()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
495 while bottomRight.parent().isValid():
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
496 bottomRight = bottomRight.parent()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
497 self.spanFirstColumn(topLeft.row(), bottomRight.row())
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
498
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
499 def resizeColumns(self):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
500 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
501 Public method to resize the columns to their contents.
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
502 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
503 for column in range(self.model().columnCount()):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
504 self.resizeColumnToContents(column)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
505
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
506 def spanFirstColumn(self, startRow, endRow):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
507 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
508 Public method to make the first column span the row for second level
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
509 items.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
510
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
511 These items contain the test results.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
512
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
513 @param startRow index of the first row to span
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
514 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
515 @param endRow index of the last row (including) to span
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
516 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
517 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
518 model = self.model()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
519 for row in range(startRow, endRow + 1):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
520 index = model.index(row, 0)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
521 for i in range(model.rowCount(index)):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
522 self.setFirstColumnSpanned(i, index, True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
523
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
524 def __canonicalIndex(self, index):
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
525 """
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
526 Private method to create the canonical index for a given index.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
527
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
528 The canonical index is the index of the first column of the test
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
529 result entry (i.e. the top-level item). If the index is invalid,
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
530 None is returned.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
531
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
532 @param index index to determine the canonical index for
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
533 @type QModelIndex
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
534 @return index of the firt column of the associated top-level item index
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
535 @rtype QModelIndex
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
536 """
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
537 if not index.isValid():
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
538 return None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
539
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
540 while index.parent().isValid(): # find the top-level node
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
541 index = index.parent()
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
542 index = index.sibling(index.row(), 0) # go to first column
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
543 return index
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
544
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
545 @pyqtSlot(QModelIndex)
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
546 def __gotoTestDefinition(self, index):
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
547 """
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
548 Private slot to show the test definition.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
549
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
550 @param index index for the double-clicked item
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
551 @type QModelIndex
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
552 """
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
553 cindex = self.__canonicalIndex(index)
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
554 filename, lineno = self.model().data(cindex, Qt.ItemDataRole.UserRole)
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
555 if filename is not None:
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
556 if lineno is None:
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
557 lineno = 1
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
558 self.goto.emit(filename, lineno)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
559
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
560 @pyqtSlot(QPoint)
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
561 def __showContextMenu(self, pos):
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
562 """
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
563 Private slot to show the context menu.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
564
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
565 @param pos relative position for the context menu
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
566 @type QPoint
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
567 """
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
568 index = self.indexAt(pos)
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
569 cindex = self.__canonicalIndex(index)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
570
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
571 contextMenu = (
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
572 self.__createContextMenu(cindex)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
573 if cindex
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
574 else self.__createBackgroundContextMenu()
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
575 )
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
576 contextMenu.exec(self.mapToGlobal(pos))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
577
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
578 def __createContextMenu(self, index):
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
579 """
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
580 Private method to create a context menu for the item pointed to by the
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
581 given index.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
582
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 @param index index of the item
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
584 @type QModelIndex
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
585 @return created context menu
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
586 @rtype QMenu
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 """
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 menu = QMenu(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
589 if self.isExpanded(index):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
590 menu.addAction(self.tr("Collapse"), lambda: self.collapse(index))
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
591 else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
592 act = menu.addAction(self.tr("Expand"), lambda: self.expand(index))
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
593 act.setEnabled(self.model().hasChildren(index))
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 menu.addSeparator()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
595
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
596 act = menu.addAction(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
597 self.tr("Show Source"), lambda: self.__gotoTestDefinition(index)
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
598 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
599 act.setEnabled(self.model().data(index, Qt.ItemDataRole.UserRole) is not None)
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
600 menu.addSeparator()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
601
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
602 menu.addAction(self.tr("Collapse All"), self.collapseAll)
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 menu.addAction(self.tr("Expand All"), self.expandAll)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
604
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
605 return menu
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
606
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
607 def __createBackgroundContextMenu(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
608 """
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 Private method to create a context menu for the background.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
610
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
611 @return created context menu
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 @rtype QMenu
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 """
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 menu = QMenu(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
615 menu.addAction(self.tr("Collapse All"), self.collapseAll)
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 menu.addAction(self.tr("Expand All"), self.expandAll)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
617
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
618 return menu
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
620
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 #
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
622 # eflag: noqa = M821, M822

eric ide

mercurial