Tue, 14 Jan 2025 17:29:56 +0100
Merged with branch 'eric7' in order 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 | |
11090
f5f5f5803935
Updated copyright for 2025.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10928
diff
changeset
|
3 | # Copyright (c) 2022 - 2025 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 the executor for the standard 'unittest' framework. |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | import contextlib |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | import json |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | import os |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
13 | import re |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
15 | from PyQt6.QtCore import QProcess, pyqtSlot |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
10928
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
17 | 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:
9313
diff
changeset
|
18 | from eric7.EricNetwork.EricJsonStreamReader import EricJsonReader |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
19 | |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9065
diff
changeset
|
20 | from .TestExecutorBase import TestExecutorBase, TestResult, TestResultCategory |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9065
diff
changeset
|
23 | class UnittestExecutor(TestExecutorBase): |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | Class implementing the executor for the standard 'unittest' framework. |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
27 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | module = "unittest" |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | name = "unittest" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
30 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | runner = os.path.join(os.path.dirname(__file__), "UnittestRunner.py") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
32 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
33 | def __init__(self, testWidget): |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
34 | """ |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
35 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
36 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
37 | @param testWidget reference to the unit test widget |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9065
diff
changeset
|
38 | @type TestingWidget |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
39 | """ |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
40 | super().__init__(testWidget) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
41 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
42 | self.__statusCategoryMapping = { |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9065
diff
changeset
|
43 | "failure": 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
|
44 | "error": 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
|
45 | "skipped": TestResultCategory.SKIP, |
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9065
diff
changeset
|
46 | "expected failure": 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
|
47 | "unexpected success": 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
|
48 | "success": TestResultCategory.OK, |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
49 | } |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
50 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
51 | self.__statusDisplayMapping = { |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
52 | "failure": self.tr("Failure"), |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
53 | "error": self.tr("Error"), |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
54 | "skipped": self.tr("Skipped"), |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
55 | "expected failure": self.tr("Expected Failure"), |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
56 | "unexpected success": self.tr("Unexpected Success"), |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
57 | "success": self.tr("Success"), |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
58 | } |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | |
9064
339bb8c8007d
Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9063
diff
changeset
|
60 | self.__testWidget = testWidget |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
61 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | def getVersions(self, interpreter): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | Public method to get the test framework version and version information |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | of its installed plugins. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
66 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | @param interpreter interpreter to be used for the test |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | @type str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | @return dictionary containing the framework name and version and the |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | list of available plugins with name and version each |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | @rtype dict |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | proc = QProcess() |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | proc.start(interpreter, [UnittestExecutor.runner, "versions"]) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | if proc.waitForFinished(3000): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | exitCode = proc.exitCode() |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | if exitCode == 0: |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | versionsStr = self.readAllOutput(proc) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | with contextlib.suppress(json.JSONDecodeError): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | return json.loads(versionsStr) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
81 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | return {} |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
83 | |
10683
779cda568acb
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
84 | def hasCoverage(self, interpreter): |
9089
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
85 | """ |
10425 | 86 | Public method to check, if the collection of coverage data is available. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
87 | |
9089
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
88 | @param interpreter interpreter to be used for the test |
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
89 | @type str |
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
90 | @return flag indicating the availability of coverage functionality |
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
91 | @rtype bool |
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
92 | """ |
10425 | 93 | proc = QProcess() |
94 | proc.start(interpreter, [UnittestExecutor.runner, "has_coverage"]) | |
95 | if proc.waitForFinished(3000): | |
96 | return proc.exitCode() == 0 | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
97 | |
10431
64157aeb0312
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10425
diff
changeset
|
98 | return False |
64157aeb0312
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10425
diff
changeset
|
99 | |
10683
779cda568acb
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
100 | def supportsPatterns(self, _interpreter): |
9313 | 101 | """ |
102 | Public method to indicate the support for test filtering using test name | |
103 | patterns or a test name pattern expression. | |
104 | ||
10683
779cda568acb
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
105 | @param _interpreter interpreter to be used for the test (unused) |
9313 | 106 | @type str |
107 | @return flag indicating support of markers | |
108 | @rtype bool | |
109 | """ | |
110 | return True | |
111 | ||
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | def createArguments(self, config): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | Public method to create the arguments needed to start the test process. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
115 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | @param config configuration for the test execution |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9065
diff
changeset
|
117 | @type TestConfig |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | @return list of process arguments |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | @rtype list of str |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
120 | """ |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
121 | args = [ |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
122 | UnittestExecutor.runner, |
10405 | 123 | "discovery" if config.discoverOnly else "runtest", |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
124 | self.reader.address(), |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
125 | str(self.reader.port()), |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
126 | ] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
127 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
128 | if config.discover: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
129 | args.extend( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
130 | [ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
131 | "discover", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
132 | "--start-directory", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
133 | config.discoveryStart, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
134 | ] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
135 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
136 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
137 | if config.failFast: |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
138 | args.append("--failfast") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
139 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
140 | if config.collectCoverage: |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
141 | args.append("--cover") |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
142 | if config.eraseCoverage: |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
143 | args.append("--cover-erase") |
9070
eab09a1ab8ce
Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9066
diff
changeset
|
144 | if config.coverageFile: |
eab09a1ab8ce
Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9066
diff
changeset
|
145 | args.append("--cover-file") |
eab09a1ab8ce
Implemented the "Show Coverage" functionality and corrected the coverage related code in UnittestRunner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9066
diff
changeset
|
146 | args.append(config.coverageFile) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
147 | |
9313 | 148 | if config.testNamePattern: |
149 | args.append("--pattern") | |
150 | args.append(config.testNamePattern) | |
151 | ||
9064
339bb8c8007d
Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9063
diff
changeset
|
152 | if config.failedOnly: |
339bb8c8007d
Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9063
diff
changeset
|
153 | args.append("--failed-only") |
339bb8c8007d
Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9063
diff
changeset
|
154 | if config.testFilename: |
339bb8c8007d
Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9063
diff
changeset
|
155 | args.append(config.testFilename) |
339bb8c8007d
Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9063
diff
changeset
|
156 | args.extend(self.__testWidget.getFailedTests()) |
10405 | 157 | elif config.testCases: |
158 | args.extend(config.testCases) | |
9089
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
159 | elif config.testFilename: |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
160 | args.append(config.testFilename) |
9313 | 161 | args.append(config.testName if config.testName else "@NONE@") |
162 | # @NONE@ is just a marker for no test name given | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
163 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
164 | return args |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
165 | |
10405 | 166 | def discover(self, config, pythonpath): |
167 | """ | |
168 | Public method to start the test discovery process. | |
169 | ||
170 | @param config configuration for the test discovery | |
171 | @type TestConfig | |
172 | @param pythonpath list of directories to be added to the Python path | |
173 | @type list of str | |
174 | """ | |
10928
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
175 | self.reader = EricJsonReader( |
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
176 | name="Unittest Reader", |
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
177 | interface=Preferences.getDebugger("NetworkInterface"), |
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
178 | parent=self, |
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
179 | ) |
10405 | 180 | self.reader.dataReceived.connect(self.__processData) |
181 | ||
182 | super().discover(config, pythonpath) | |
183 | ||
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
184 | def start(self, config, pythonpath): |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
185 | """ |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
186 | Public method to start the testing process. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
187 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
188 | @param config configuration for the test execution |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9065
diff
changeset
|
189 | @type TestConfig |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
190 | @param pythonpath list of directories to be added to the Python path |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
191 | @type list of str |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
192 | """ |
10928
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
193 | self.reader = EricJsonReader( |
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
194 | name="Unittest Reader", |
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
195 | interface=Preferences.getDebugger("NetworkInterface"), |
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
196 | parent=self, |
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
197 | ) |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
198 | self.reader.dataReceived.connect(self.__processData) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
199 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
200 | super().start(config, pythonpath) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
201 | |
10415 | 202 | def startDebug(self, config, pythonpath, debugger): |
203 | """ | |
204 | Public method to start the test run with debugger support. | |
205 | ||
206 | @param config configuration for the test execution | |
207 | @type TestConfig | |
208 | @param pythonpath list of directories to be added to the Python path | |
209 | @type list of str | |
210 | @param debugger refference to the debugger interface | |
211 | @type DebugUI | |
212 | """ | |
10928
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
213 | self.reader = EricJsonReader( |
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
214 | name="Unittest Reader", |
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
215 | interface=Preferences.getDebugger("NetworkInterface"), |
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
216 | parent=self, |
46651e194fbe
Refactored some packages, modules and code to allow extracting the 'EricXxx' packages into a library project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10683
diff
changeset
|
217 | ) |
10415 | 218 | self.reader.dataReceived.connect(self.__processData) |
219 | ||
220 | super().startDebug(config, pythonpath, debugger) | |
221 | ||
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
222 | def finished(self): |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
223 | """ |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
224 | Public method handling the unit test process been finished. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
225 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
226 | This method should read the results (if necessary) and emit the signal |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
227 | testFinished. |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
228 | """ |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
229 | self.reader.close() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
230 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
231 | output = self.readAllOutput() |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
232 | self.testFinished.emit([], output) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
233 | |
10415 | 234 | super().finished() |
235 | ||
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
236 | @pyqtSlot(object) |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
237 | def __processData(self, data): |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | """ |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
239 | Private slot to process the received data. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
240 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
241 | @param data data object received |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
242 | @type dict |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
243 | """ |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
244 | # error collecting tests |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
245 | if data["event"] == "collecterror": |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
246 | self.collectError.emit([("", data["error"])]) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
247 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
248 | # tests collected |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
249 | elif data["event"] == "collected": |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
250 | self.collected.emit( |
10405 | 251 | [ |
252 | ( | |
253 | t["id"], | |
254 | t["name"], | |
255 | t["description"], | |
256 | t["filename"], | |
257 | 0, | |
258 | t["id"].split("."), | |
259 | ) | |
260 | for t in data["tests"] | |
261 | ] | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
262 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
263 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
264 | # test started |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
265 | elif data["event"] == "started": |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
266 | self.startTest.emit((data["id"], data["name"], data["description"])) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
267 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
268 | # test result |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
269 | elif data["event"] == "result": |
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
|
270 | filename, lineno = None, None |
9089
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
271 | tracebackLines = data.get("traceback", "").splitlines() |
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
272 | if tracebackLines: |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
273 | # find the last entry matching the pattern |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
274 | for index in range(len(tracebackLines) - 1, -1, -1): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
275 | fmatch = re.search( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
276 | r'File "(.*?)", line (\d*?),.*', tracebackLines[index] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
277 | ) |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
278 | if fmatch: |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
279 | break |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
280 | if fmatch: |
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
|
281 | filename = fmatch.group(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
|
282 | lineno = int(fmatch.group(2)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
283 | |
9089
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
284 | message = data.get("shortmsg", "") |
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
285 | if not message and tracebackLines: |
9547
38fa6ca90253
Fixed an issue in UnittestExecutor causing failing asserts with multi element values not (e.g. tuple, list) not to be shown and raising an exception instead (caused by a wrong assumption about the reported traceback).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
286 | # search the line containing the assertion error |
38fa6ca90253
Fixed an issue in UnittestExecutor causing failing asserts with multi element values not (e.g. tuple, list) not to be shown and raising an exception instead (caused by a wrong assumption about the reported traceback).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
287 | for index in range(len(tracebackLines) - 1, -1, -1): |
38fa6ca90253
Fixed an issue in UnittestExecutor causing failing asserts with multi element values not (e.g. tuple, list) not to be shown and raising an exception instead (caused by a wrong assumption about the reported traceback).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
288 | line = tracebackLines[index].strip() |
38fa6ca90253
Fixed an issue in UnittestExecutor causing failing asserts with multi element values not (e.g. tuple, list) not to be shown and raising an exception instead (caused by a wrong assumption about the reported traceback).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
289 | if line.startswith("AssertionError:"): |
38fa6ca90253
Fixed an issue in UnittestExecutor causing failing asserts with multi element values not (e.g. tuple, list) not to be shown and raising an exception instead (caused by a wrong assumption about the reported traceback).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
290 | message = line.replace("AssertionError:", "").strip() |
38fa6ca90253
Fixed an issue in UnittestExecutor causing failing asserts with multi element values not (e.g. tuple, list) not to be shown and raising an exception instead (caused by a wrong assumption about the reported traceback).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
291 | break |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
292 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
293 | self.testResult.emit( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
294 | TestResult( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
295 | category=self.__statusCategoryMapping[data["status"]], |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
296 | status=self.__statusDisplayMapping[data["status"]], |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
297 | name=data["name"], |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
298 | id=data["id"], |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
299 | description=data["description"], |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
300 | message=message, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
301 | extra=tracebackLines, |
10050
3750abc45d5e
Corrected some code style issues detected by the extended checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
302 | duration=data.get("duration_ms"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
303 | filename=filename, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
304 | lineno=lineno, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
305 | subtestResult=data.get("subtest", False), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
306 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
307 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
308 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
309 | # test run finished |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
310 | elif data["event"] == "finished": |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
311 | self.testRunFinished.emit(data["tests"], data["duration_s"]) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
312 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
313 | # coverage data |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
314 | elif data["event"] == "coverage": |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
315 | self.coverageDataSaved.emit(data["file"]) |