src/eric7/Testing/TestResultsTree.py

Wed, 01 Mar 2023 09:05:47 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 01 Mar 2023 09:05:47 +0100
branch
eric7-maintenance
changeset 9832
3885b9d7bd31
parent 9654
7328efba128b
parent 9786
f94b530722af
child 10079
0222a480e93d
permissions
-rw-r--r--

Merged with branch 'eric7' to prepare a new release.

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
9653
e67609152c5e Updated copyright for 2023.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9502
diff changeset
3 # Copyright (c) 2022 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>
9059
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
9502
6091145e189e 'Blacked' the code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9500
diff changeset
163 and idx == TopLevelId
6091145e189e 'Blacked' the code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9500
diff changeset
164 and column == TestResultsModel.DurationColumn
9500
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
165 ):
5771348ded12 Corrected some code style issues and changed some suppressed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
166 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
167 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
168 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
169 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
170
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
171 return None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
172
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
173 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
174 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 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
176
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 @param section section number
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 @type int
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 @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
180 @type Qt.Orientation
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 @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
182 @type Qt.ItemDataRole (optional)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 @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
184 @rtype str
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
187 orientation == Qt.Orientation.Horizontal
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
188 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
189 ):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 return TestResultsModel.Headers[section]
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 else:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 return None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
193
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
194 def parent(self, index):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
195 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
196 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
197
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
198 @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
199 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
200 @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
201 @rtype QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
202 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
203 if not index.isValid():
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
204 return QModelIndex()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
205
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
206 idx = index.internalId()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
207 if idx == TopLevelId:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
208 return QModelIndex()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
209 else:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
210 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
211
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 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
213 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 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
215
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 @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
217 @type QModelIndex (optional)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 @return number of rows
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 @rtype int
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 if not parent.isValid():
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 return len(self.__testResults)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
223
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
224 if (
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
225 parent.internalId() == TopLevelId
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
226 and parent.column() == 0
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
227 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
228 ):
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 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
230
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 return 0
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 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
234 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 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
236
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 @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
238 @type QModelIndex (optional)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 @return number of columns
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 @rtype int
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 if not parent.isValid():
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 return len(TestResultsModel.Headers)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 else:
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 return 1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
246
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 def clear(self):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 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
250 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 self.beginResetModel()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 self.__testResults.clear()
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 self.endResetModel()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
254
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
255 self.summary.emit("")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
256
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
257 def sort(self, column, order):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
258 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
259 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
260
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
261 @param column sort column number
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
262 @type int
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
263 @param order sort order
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
264 @type Qt.SortOrder
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
265 """ # __IGNORE_WARNING_D234r__
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
266
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
267 def durationKey(result):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
268 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
269 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
270
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
271 @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
272 @type TestResult
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
273 @return sort key
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
274 @rtype float
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
275 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
276 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
277
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
278 self.beginResetModel()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
279 reverse = order == Qt.SortOrder.DescendingOrder
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
280 if column == TestResultsModel.StatusColumn:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
281 self.__testResults.sort(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
282 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
283 )
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
284 elif column == TestResultsModel.NameColumn:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
285 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
286 elif column == TestResultsModel.MessageColumn:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
287 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
288 elif column == TestResultsModel.DurationColumn:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
289 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
290 self.endResetModel()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
291
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
292 def getTestResults(self):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
293 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
294 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
295
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
296 @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
297 @rtype list of TestResult
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
298 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
299 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
300
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
301 def setTestResults(self, testResults):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
302 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
303 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
304
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
305 @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
306 @type list of TestResult
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
307 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
308 self.beginResetModel()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
309 self.__testResults = copy.deepcopy(testResults)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
310 self.endResetModel()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
311
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
312 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
313
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
314 def addTestResults(self, testResults):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
315 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
316 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
317 model.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
318
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
319 @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
320 @type list of TestResult
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
321 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
322 firstRow = len(self.__testResults)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
323 lastRow = firstRow + len(testResults) - 1
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
324 self.beginInsertRows(QModelIndex(), firstRow, lastRow)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
325 self.__testResults.extend(testResults)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
326 self.endInsertRows()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
327
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
328 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
329
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
330 def updateTestResults(self, testResults):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
331 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
332 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
333
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
334 @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
335 @type list of TestResult
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
336 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
337 minIndex = None
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
338 maxIndex = None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
339
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
340 testResultsToBeAdded = []
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
341
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
342 for testResult in testResults:
9786
f94b530722af Corrected some code style and formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
343 for index, currentResult in enumerate(self.__testResults):
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
344 if currentResult.id == testResult.id:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
345 self.__testResults[index] = testResult
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
346 if minIndex is None:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
347 minIndex = index
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
348 maxIndex = index
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
349 else:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
350 minIndex = min(minIndex, index)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
351 maxIndex = max(maxIndex, index)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
352
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
353 break
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
354 else:
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
355 # 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
356 # 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
357 testResultsToBeAdded.append(testResult)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
358
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
359 if minIndex is not None:
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
360 self.dataChanged.emit(
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
361 self.index(minIndex, 0),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
362 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
363 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
364
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
365 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
366
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
367 if testResultsToBeAdded:
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
368 self.addTestResults(testResultsToBeAdded)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
369
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
370 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
371 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
372 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
373
9064
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
374 @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
375 @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
376 """
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
377 failedIds = [
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
378 res.id
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
379 for res in self.__testResults
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
380 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
381 ]
339bb8c8007d Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9063
diff changeset
382 return failedIds
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
383
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
384 def __summary(self):
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
385 """
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
386 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
387
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
388 @return test results summary text
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
389 @rtype str
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
390 """
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
391 if len(self.__testResults) == 0:
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
392 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
393
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
394 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
395 if all(
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
396 counts[category] == 0
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
397 for category in (
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
398 TestResultCategory.FAIL,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
399 TestResultCategory.OK,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
400 TestResultCategory.SKIP,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
401 )
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
402 ):
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
403 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
404
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
405 return self.tr(
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
406 "%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
407 " {2} skipped, {3} pending",
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
408 "",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
409 len(self.__testResults),
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
410 ).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
411 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
412 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
413 counts[TestResultCategory.SKIP],
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
414 counts[TestResultCategory.PENDING],
9063
f1d7dd7ae471 Corrected the code dealing with subtests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9062
diff changeset
415 )
9059
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
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 class TestResultsTreeView(QTreeView):
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 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
421
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 @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
423 and line number
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
425
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 goto = pyqtSignal(str, int)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
427
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 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
429 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
431
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 @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
433 @type QWidget (optional)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 """
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 super().__init__(parent)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
436
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 self.setItemsExpandable(True)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 self.setExpandsOnDoubleClick(False)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 self.setSortingEnabled(True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
440
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 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
442 self.header().setSortIndicatorShown(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
443
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
444 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
445
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 # connect signals and slots
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 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
448 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
449
9059
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(self.sortByColumn)
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 self.header().sortIndicatorChanged.connect(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
452 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
453 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
454
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
455 def reset(self):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
456 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
457 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
458 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
459 super().reset()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
460
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
461 self.resizeColumns()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
462 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
463
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
464 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
465 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
466 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
467
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
468 @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
469 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
470 @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
471 @type int
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
472 @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
473 @type int
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
474 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
475 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
476
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
477 self.resizeColumns()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
478 self.spanFirstColumn(startRow, endRow)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
479
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
480 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
481 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
482 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
483
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
484 @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
485 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
486 @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
487 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
488 @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
489 @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
490 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
491 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
492
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
493 self.resizeColumns()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
494 while topLeft.parent().isValid():
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
495 topLeft = topLeft.parent()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
496 while bottomRight.parent().isValid():
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
497 bottomRight = bottomRight.parent()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
498 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
499
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
500 def resizeColumns(self):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
501 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
502 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
503 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
504 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
505 self.resizeColumnToContents(column)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
506
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
507 def spanFirstColumn(self, startRow, endRow):
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
508 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
509 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
510 items.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
511
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
512 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
513
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
514 @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
515 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
516 @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
517 @type QModelIndex
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
518 """
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
519 model = self.model()
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
520 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
521 index = model.index(row, 0)
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
522 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
523 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
524
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
525 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
526 """
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
527 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
528
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
529 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
530 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
531 None is returned.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
532
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
533 @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
534 @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
535 @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
536 @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
537 """
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 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
539 return None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
540
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
541 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
542 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
543 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
544 return index
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
545
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
546 @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
547 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
548 """
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
549 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
550
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
551 @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
552 @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
553 """
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 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
555 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
556 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
557 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
558 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
559 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
560
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
561 @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
562 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
563 """
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
564 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
565
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
566 @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
567 @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
568 """
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 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
570 cindex = self.__canonicalIndex(index)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
571
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
572 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
573 self.__createContextMenu(cindex)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
574 if cindex
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
575 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
576 )
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
577 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
578
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
579 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
580 """
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 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
582 given index.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
583
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
584 @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
585 @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
586 @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
587 @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
588 """
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 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
590 if self.isExpanded(index):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
591 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
592 else:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
593 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
594 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
595 menu.addSeparator()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
596
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
597 act = menu.addAction(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
598 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
599 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
600 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
601 menu.addSeparator()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
602
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
603 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
604 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
605
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
606 return menu
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
607
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
608 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
609 """
39405e6eba20 Integrated the new testing widget into the eric IDE (compared to as a standalone app) and implemented the 'Show Source' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9064
diff changeset
610 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
611
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
612 @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
613 @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
614 """
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 = 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
616 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
617 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
618
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
619 return menu
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
621
9059
e7fd342f8bfc Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 #
9062
7f27bf3b50c3 Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9059
diff changeset
623 # eflag: noqa = M821, M822

eric ide

mercurial