Wed, 30 Nov 2022 09:19:51 +0100
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 | |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the executor base class for the various testing frameworks |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | and supporting classes. |
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 | |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | import os |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
12 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | from dataclasses import dataclass |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | from enum import IntEnum |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
16 | from PyQt6.QtCore import QObject, QProcess, QProcessEnvironment, pyqtSignal |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
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 import Preferences |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9064
diff
changeset
|
21 | class TestResultCategory(IntEnum): |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | Class defining the supported result categories. |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
25 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
26 | RUNNING = 0 |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | FAIL = 1 |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | OK = 2 |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | SKIP = 3 |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | PENDING = 4 |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | @dataclass |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9064
diff
changeset
|
34 | class TestResult: |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | Class containing the test result data. |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
38 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
39 | category: TestResultCategory # result category |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | status: str # test status |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
41 | name: str # test name |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | id: str # test id |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
43 | description: str = "" # short description of test |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | message: str = "" # short result message |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
45 | extra: list = None # additional information text |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
46 | duration: float = None # test duration |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
47 | filename: str = None # file name of a failed test |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
48 | lineno: int = None # line number of a failed test |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
49 | subtestResult: bool = False # flag indicating the result of a subtest |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | @dataclass |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9064
diff
changeset
|
53 | class TestConfig: |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | Class containing the test run configuration. |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
57 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
58 | interpreter: str # path of the Python interpreter |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | discover: bool # auto discovery flag |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
60 | discoveryStart: str # start directory for auto discovery |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
61 | testFilename: str # name of the test script |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
62 | testName: str # name of the test function |
9311 | 63 | testMarkerExpression: str # marker expression for test selection |
9313 | 64 | testNamePattern: str # test name pattern expression or list |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
65 | failFast: bool # stop on first fail |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
66 | failedOnly: bool # run failed tests only |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
67 | collectCoverage: bool # coverage collection flag |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
68 | eraseCoverage: bool # erase coverage data first |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
69 | coverageFile: str # name of the coverage data file |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9064
diff
changeset
|
72 | class TestExecutorBase(QObject): |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | Base class for test framework specific implementations. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
75 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
76 | @signal collected(list of tuple of (str, str, str)) emitted after all tests |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
77 | have been collected. Tuple elements are the test id, the test name and |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
78 | a short description of the test. |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | @signal collectError(list of tuple of (str, str)) emitted when errors |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | are encountered during test collection. Tuple elements are the |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | test name and the error message. |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
82 | @signal startTest(tuple of (str, str, str) emitted before tests are run. |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
83 | Tuple elements are test id, test name and short description. |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9064
diff
changeset
|
84 | @signal testResult(TestResult) emitted when a test result is ready |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | @signal testFinished(list, str) emitted when the test has finished. |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | The elements are the list of test results and the captured output |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | of the test worker (if any). |
9064
339bb8c8007d
Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9063
diff
changeset
|
88 | @signal testRunAboutToBeStarted() emitted just before the test run will |
339bb8c8007d
Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9063
diff
changeset
|
89 | be started. |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
90 | @signal testRunFinished(int, float) emitted when the test run has finished. |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
91 | The elements are the number of tests run and the duration in seconds |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | @signal stop() emitted when the test process is being stopped. |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
93 | @signal coverageDataSaved(str) emitted after the coverage data was saved. |
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
94 | The element is the absolute path of the coverage data file. |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
96 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | collected = pyqtSignal(list) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | collectError = pyqtSignal(list) |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
99 | startTest = pyqtSignal(tuple) |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9064
diff
changeset
|
100 | testResult = pyqtSignal(TestResult) |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | testFinished = pyqtSignal(list, str) |
9064
339bb8c8007d
Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9063
diff
changeset
|
102 | testRunAboutToBeStarted = pyqtSignal() |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
103 | testRunFinished = pyqtSignal(int, float) |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | stop = pyqtSignal() |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
105 | coverageDataSaved = pyqtSignal(str) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
106 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | module = "" |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | name = "" |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | runner = "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
110 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
111 | def __init__(self, testWidget): |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
114 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | @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:
9064
diff
changeset
|
116 | @type TestingWidget |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | super().__init__(testWidget) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
119 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | self.__process = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
121 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | @classmethod |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | def isInstalled(cls, interpreter): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | Class method to check whether a test framework is installed. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
126 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | The test is performed by checking, if a module loader can found. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
128 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | @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
|
130 | @type str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | @return flag indicating the test framework module is installed |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | @rtype bool |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | if cls.runner: |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | proc = QProcess() |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | proc.start(interpreter, [cls.runner, "installed"]) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | if proc.waitForFinished(3000): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | exitCode = proc.exitCode() |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | return exitCode == 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
140 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | return False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
142 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | def getVersions(self, interpreter): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | 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
|
146 | of its installed plugins. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
147 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | @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
|
149 | @type str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | @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
|
151 | 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
|
152 | @rtype dict |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | return {} |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
155 | |
9089
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
156 | def hasCoverage(self, interpreter): |
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
157 | """ |
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
158 | Public method to get the test framework version and version information |
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
159 | of its installed plugins. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
160 | |
9089
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
161 | @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
|
162 | @type str |
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
163 | @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
|
164 | @rtype bool |
9311 | 165 | """ |
166 | return False | |
167 | ||
9313 | 168 | def supportsPatterns(self, interpreter): |
169 | """ | |
170 | Public method to indicate the support for test filtering using test name | |
171 | patterns or a test name pattern expression. | |
172 | ||
173 | @param interpreter interpreter to be used for the test | |
174 | @type str | |
175 | @return flag indicating support of markers | |
176 | @rtype bool | |
177 | """ | |
178 | return False | |
179 | ||
9311 | 180 | def supportsMarkers(self, interpreter): |
181 | """ | |
182 | Public method to indicate the support for test filtering using markers and/or | |
183 | marker expressions. | |
184 | ||
185 | @param interpreter interpreter to be used for the test | |
186 | @type str | |
187 | @return flag indicating support of markers | |
188 | @rtype bool | |
9089
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
189 | """ |
9311 | 190 | return False |
191 | ||
192 | def getMarkers(self, interpreter, workdir): | |
193 | """ | |
194 | Public method to get the list of defined markers. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
195 | |
9311 | 196 | @param interpreter interpreter to be used for the test |
197 | @type str | |
198 | @param workdir name of the working directory | |
199 | @type str | |
200 | @return dictionary containing the marker as key and the associated description | |
201 | as value | |
202 | @rtype dict | |
203 | """ | |
204 | return {} | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
205 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | def createArguments(self, config): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | 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
|
209 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | @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:
9064
diff
changeset
|
211 | @type TestConfig |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | @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
|
213 | @rtype list of str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | @exception NotImplementedError this method needs to be implemented by |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | derived classes |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | raise NotImplementedError |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
218 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | return [] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
220 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | def _prepareProcess(self, workDir, pythonpath): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | Protected method to prepare a process object to be started. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
224 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | @param workDir working directory |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | @type str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | @param pythonpath list of directories to be added to the Python path |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | @type list of str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | @return prepared process object |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | @rtype QProcess |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | process = QProcess(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
233 | process.setProcessChannelMode(QProcess.ProcessChannelMode.MergedChannels) |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | process.setWorkingDirectory(workDir) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | process.finished.connect(self.finished) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | if pythonpath: |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | env = QProcessEnvironment.systemEnvironment() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
238 | currentPythonPath = env.value("PYTHONPATH", None) |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | newPythonPath = os.pathsep.join(pythonpath) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | if currentPythonPath: |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | newPythonPath += os.pathsep + currentPythonPath |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
242 | env.insert("PYTHONPATH", newPythonPath) |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | process.setProcessEnvironment(env) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
244 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | return process |
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 start(self, config, pythonpath): |
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 start the testing process. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
250 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | @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:
9064
diff
changeset
|
252 | @type TestConfig |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | @param pythonpath list of directories to be added to the Python path |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
254 | @type list of str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
255 | @exception RuntimeError raised if the the testing process did not start |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
256 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
257 | workDir = ( |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | config.discoveryStart |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
259 | if config.discover |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
260 | else os.path.dirname(config.testFilename) |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
261 | ) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | self.__process = self._prepareProcess(workDir, pythonpath) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
263 | testArgs = self.createArguments(config) |
9064
339bb8c8007d
Implemented the "Rerun Failed" functionality for the new unit test interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9063
diff
changeset
|
264 | self.testRunAboutToBeStarted.emit() |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | self.__process.start(config.interpreter, testArgs) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
266 | running = self.__process.waitForStarted() |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
267 | if not running: |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | raise RuntimeError |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
269 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | def finished(self): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
272 | 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
|
273 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | This method should read the results (if necessary) and emit the signal |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
275 | testFinished. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
276 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
277 | @exception NotImplementedError this method needs to be implemented by |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
278 | derived classes |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
279 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
280 | raise NotImplementedError |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
281 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
282 | def readAllOutput(self, process=None): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
283 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
284 | Public method to read all output of the test process. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
285 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
286 | @param process reference to the process object |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | @type QProcess |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | @return test process output |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | @rtype str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
290 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
291 | if process is None: |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | process = self.__process |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
293 | output = ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
294 | str( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
295 | process.readAllStandardOutput(), |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
296 | Preferences.getSystem("IOEncoding"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
297 | "replace", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
298 | ).strip() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
299 | if process |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
300 | else "" |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
301 | ) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
302 | return output |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
303 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
304 | def stopIfRunning(self): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
305 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
306 | Public method to stop the testing process, if it is running. |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
307 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
308 | if self.__process and self.__process.state() == QProcess.ProcessState.Running: |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
309 | self.__process.terminate() |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
310 | self.__process.waitForFinished(2000) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
311 | self.__process.kill() |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
312 | self.__process.waitForFinished(3000) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
313 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
314 | self.stop.emit() |