Wed, 24 Apr 2024 10:14:16 +0200
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 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10426
diff
changeset
|
3 | # Copyright (c) 2022 - 2024 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 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 | |
10405 | 13 | from dataclasses import dataclass, field |
9059
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 |
10404 | 47 | filename: str = None # file name of a (failed) test |
48 | lineno: int = None # line number of a (failed) test | |
9221
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 |
10405 | 59 | discover: bool = False # auto discovery flag |
60 | discoveryStart: str = "" # start directory for auto discovery | |
61 | testCases: list = field(default_factory=list) # list of selected test cases | |
62 | testFilename: str = "" # name of the test script | |
63 | testName: str = "" # name of the test function | |
64 | testMarkerExpression: str = "" # marker expression for test selection | |
65 | testNamePattern: str = "" # test name pattern expression or list | |
66 | failFast: bool = False # stop on first fail | |
67 | failedOnly: bool = False # run failed tests only | |
68 | collectCoverage: bool = False # coverage collection flag | |
69 | eraseCoverage: bool = False # erase coverage data first | |
70 | coverageFile: str = "" # name of the coverage data file | |
71 | discoverOnly: bool = False # test discovery only | |
10415 | 72 | venvName: str = "" # name of the virtual environment |
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 | |
9066
a219ade50f7c
Performed some refactoring to avoid possible name clashes on case-insensitive systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9064
diff
changeset
|
75 | class TestExecutorBase(QObject): |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | 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
|
78 | |
10405 | 79 | @signal collected(list of tuple of (str, str, str, str, int, list)) emitted after |
80 | all tests have been collected. Tuple elements are the test id, the test name, | |
81 | a short description of the test, the test file name, the line number of | |
82 | the test and the elements of the test path as a list. | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | @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
|
84 | 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
|
85 | 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
|
86 | @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
|
87 | 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
|
88 | @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
|
89 | @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
|
90 | 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
|
91 | 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
|
92 | @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
|
93 | be started. |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
94 | @signal testRunFinished(int, float) emitted when the test run has finished. |
10405 | 95 | 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
|
96 | @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
|
97 | @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
|
98 | The element is the absolute path of the coverage data file. |
10405 | 99 | @signal discoveryAboutToBeStarted() emitted just before the test discovery |
100 | will be started | |
101 | @signal discoveryFinished(int, float) emitted when the discovery has finished. | |
102 | The elements are the number of discovered tests 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
|
103 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
104 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | collected = pyqtSignal(list) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | collectError = pyqtSignal(list) |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
107 | 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
|
108 | testResult = pyqtSignal(TestResult) |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | 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
|
110 | testRunAboutToBeStarted = pyqtSignal() |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
111 | 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
|
112 | stop = pyqtSignal() |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
113 | coverageDataSaved = pyqtSignal(str) |
10405 | 114 | discoveryAboutToBeStarted = pyqtSignal() |
115 | discoveryFinished = pyqtSignal(int, float) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
116 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | module = "" |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | name = "" |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | runner = "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
120 | |
9062
7f27bf3b50c3
Implemented most of the 'unittest' executor and runner.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9059
diff
changeset
|
121 | 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
|
122 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
124 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | @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
|
126 | @type TestingWidget |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | super().__init__(testWidget) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
129 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | self.__process = None |
10415 | 131 | self.__debugger = None |
132 | ||
133 | self._language = "Python3" | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
134 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | @classmethod |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | def isInstalled(cls, interpreter): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | 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
|
139 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | 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
|
141 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | @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
|
143 | @type str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | @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
|
145 | @rtype bool |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | if cls.runner: |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | proc = QProcess() |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | 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
|
150 | if proc.waitForFinished(3000): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | exitCode = proc.exitCode() |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | return exitCode == 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
153 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | return False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
155 | |
10069
435cc5875135
Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
156 | def getVersions(self, interpreter): # noqa: U100 |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | 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
|
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 | |
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
|
161 | @param interpreter interpreter to be used for the test (unused) |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | @type str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | @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
|
164 | 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
|
165 | @rtype dict |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | return {} |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
168 | |
10069
435cc5875135
Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
169 | def hasCoverage(self, interpreter): # noqa: U100 |
9089
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
170 | """ |
10426 | 171 | 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
|
172 | |
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
|
173 | @param interpreter interpreter to be used for the test (unused) |
9089
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
174 | @type str |
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
175 | @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
|
176 | @rtype bool |
9311 | 177 | """ |
178 | return False | |
179 | ||
10069
435cc5875135
Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
180 | def supportsPatterns(self, interpreter): # noqa: U100 |
9313 | 181 | """ |
182 | Public method to indicate the support for test filtering using test name | |
183 | patterns or a test name pattern expression. | |
184 | ||
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
|
185 | @param interpreter interpreter to be used for the test (unused) |
9313 | 186 | @type str |
187 | @return flag indicating support of markers | |
188 | @rtype bool | |
189 | """ | |
190 | return False | |
191 | ||
10069
435cc5875135
Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
192 | def supportsMarkers(self, interpreter): # noqa: U100 |
9311 | 193 | """ |
194 | Public method to indicate the support for test filtering using markers and/or | |
195 | marker expressions. | |
196 | ||
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
|
197 | @param interpreter interpreter to be used for the test (unused) |
9311 | 198 | @type str |
199 | @return flag indicating support of markers | |
200 | @rtype bool | |
9089
b48a6d0f6309
Implemented support for the 'pytest' framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9070
diff
changeset
|
201 | """ |
9311 | 202 | return False |
203 | ||
10069
435cc5875135
Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
204 | def getMarkers(self, interpreter, workdir): # noqa: U100 |
9311 | 205 | """ |
206 | 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
|
207 | |
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
|
208 | @param interpreter interpreter to be used for the test (unused) |
9311 | 209 | @type str |
210 | @param workdir name of the working directory | |
211 | @type str | |
212 | @return dictionary containing the marker as key and the associated description | |
213 | as value | |
214 | @rtype dict | |
215 | """ | |
216 | return {} | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
217 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | def createArguments(self, config): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | 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
|
221 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | @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
|
223 | @type TestConfig |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | @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
|
225 | @rtype list of str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | @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
|
227 | derived classes |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | raise NotImplementedError |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
230 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | return [] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
232 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | 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
|
234 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | 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
|
236 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | @param workDir working directory |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | @type str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | @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
|
240 | @type list of str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | @return prepared process object |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | @rtype QProcess |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | process = QProcess(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
245 | 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
|
246 | process.setWorkingDirectory(workDir) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | 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
|
248 | if pythonpath: |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | env = QProcessEnvironment.systemEnvironment() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
250 | 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
|
251 | 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
|
252 | if currentPythonPath: |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | newPythonPath += os.pathsep + currentPythonPath |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
254 | 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
|
255 | process.setProcessEnvironment(env) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
256 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
257 | return process |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
258 | |
10405 | 259 | def discover(self, config, pythonpath): |
260 | """ | |
261 | Public method to start the test discovery process. | |
262 | ||
263 | @param config configuration for the test discovery | |
264 | @type TestConfig | |
265 | @param pythonpath list of directories to be added to the Python path | |
266 | @type list of str | |
267 | @exception RuntimeError raised if the the test discovery process did not start | |
268 | @exception ValueError raised if no start directory for the test discovery was | |
269 | given | |
270 | """ | |
271 | if not config.discoveryStart: | |
272 | raise ValueError("No discovery start directory given.") | |
273 | ||
274 | self.__process = self._prepareProcess(config.discoveryStart, pythonpath) | |
275 | discoveryArgs = self.createArguments(config) | |
276 | self.discoveryAboutToBeStarted.emit() | |
277 | self.__process.start(config.interpreter, discoveryArgs) | |
278 | running = self.__process.waitForStarted() | |
279 | if not running: | |
280 | raise RuntimeError("Test discovery process did not start.") | |
281 | ||
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
282 | 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
|
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 start the testing 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 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
|
287 | @type TestConfig |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | @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
|
289 | @type list of str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
290 | @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
|
291 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | workDir = ( |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
293 | config.discoveryStart |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
294 | if config.discover |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
295 | 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
|
296 | ) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
297 | 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
|
298 | 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
|
299 | self.testRunAboutToBeStarted.emit() |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
300 | 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
|
301 | running = self.__process.waitForStarted() |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
302 | if not running: |
10069
435cc5875135
Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
303 | raise RuntimeError("Test process did not start.") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
304 | |
10415 | 305 | def startDebug(self, config, pythonpath, debugger): |
306 | """ | |
307 | Public method to start the test run with debugger support. | |
308 | ||
309 | @param config configuration for the test execution | |
310 | @type TestConfig | |
311 | @param pythonpath list of directories to be added to the Python path | |
312 | @type list of str | |
313 | @param debugger refference to the debugger interface | |
314 | @type DebugUI | |
315 | """ | |
316 | workDir = ( | |
317 | config.discoveryStart | |
318 | if config.discover | |
319 | else os.path.dirname(config.testFilename) | |
320 | ) | |
321 | testArgs = self.createArguments(config) | |
322 | if pythonpath: | |
323 | currentPythonPath = os.environ.get("PYTHONPATH") | |
324 | newPythonPath = os.pathsep.join(pythonpath) | |
325 | if currentPythonPath: | |
326 | newPythonPath += os.pathsep + currentPythonPath | |
10417
c6011e501282
Modernized some code and converted Debug Client and Debugger source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10415
diff
changeset
|
327 | environment = {"PYTHONPATH": newPythonPath} |
10415 | 328 | else: |
10417
c6011e501282
Modernized some code and converted Debug Client and Debugger source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10415
diff
changeset
|
329 | environment = {} |
10415 | 330 | |
331 | self.__debugger = debugger | |
332 | self.__debugger.debuggingFinished.connect(self.finished) | |
333 | self.testRunAboutToBeStarted.emit() | |
334 | ||
335 | self.__debugger.debugInternalScript( | |
336 | venvName=config.venvName, | |
337 | scriptName=testArgs[0], | |
338 | argv=testArgs[1:], | |
339 | workDir=workDir, | |
340 | environment=environment, | |
341 | clientType=self._language, | |
342 | forProject=False, | |
343 | ) | |
344 | ||
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
345 | def finished(self): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
346 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
347 | 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
|
348 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
349 | 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
|
350 | testFinished. |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
351 | """ |
10415 | 352 | if self.__debugger is not None: |
353 | self.__debugger.debuggingFinished.disconnect(self.finished) | |
354 | self.__debugger = None | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
355 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
356 | 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
|
357 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
358 | 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
|
359 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
360 | @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
|
361 | @type QProcess |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
362 | @return test process output |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
363 | @rtype str |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
364 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
365 | if process is None: |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
366 | process = self.__process |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
367 | output = ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
368 | str( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
369 | process.readAllStandardOutput(), |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
370 | Preferences.getSystem("IOEncoding"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
371 | "replace", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
372 | ).strip() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
373 | if process |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
374 | else "" |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
375 | ) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
376 | return output |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
377 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
378 | def stopIfRunning(self): |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
379 | """ |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | 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
|
381 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
382 | 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
|
383 | self.__process.terminate() |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
384 | self.__process.waitForFinished(2000) |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
385 | self.__process.kill() |
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
386 | self.__process.waitForFinished(3000) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
387 | |
9059
e7fd342f8bfc
Implemented the basic functionality of the new unit test framework.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
388 | self.stop.emit() |