orionis 0.314.0__py3-none-any.whl → 0.315.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orionis/metadata/framework.py +1 -1
- orionis/test/contracts/printer.py +188 -0
- orionis/test/contracts/test_unit.py +42 -16
- orionis/test/output/printer.py +448 -0
- orionis/test/suite/test_unit.py +574 -659
- {orionis-0.314.0.dist-info → orionis-0.315.0.dist-info}/METADATA +1 -1
- {orionis-0.314.0.dist-info → orionis-0.315.0.dist-info}/RECORD +12 -10
- tests/testing/test_testing_unit.py +3 -8
- {orionis-0.314.0.dist-info → orionis-0.315.0.dist-info}/WHEEL +0 -0
- {orionis-0.314.0.dist-info → orionis-0.315.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.314.0.dist-info → orionis-0.315.0.dist-info}/top_level.txt +0 -0
- {orionis-0.314.0.dist-info → orionis-0.315.0.dist-info}/zip-safe +0 -0
orionis/metadata/framework.py
CHANGED
@@ -0,0 +1,188 @@
|
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
from typing import Any, Dict
|
3
|
+
|
4
|
+
class ITestPrinter(ABC):
|
5
|
+
|
6
|
+
@abstractmethod
|
7
|
+
def print(
|
8
|
+
self,
|
9
|
+
value: Any
|
10
|
+
) -> None:
|
11
|
+
"""
|
12
|
+
Prints a value to the console using the rich console.
|
13
|
+
Parameters
|
14
|
+
----------
|
15
|
+
value : Any
|
16
|
+
The value to be printed. It can be a string, object, or any other type.
|
17
|
+
Notes
|
18
|
+
-----
|
19
|
+
- If the value is a string, it is printed directly.
|
20
|
+
- If the value is an object, its string representation is printed.
|
21
|
+
- If the value is a list, each item is printed on a new line.
|
22
|
+
"""
|
23
|
+
pass
|
24
|
+
|
25
|
+
@abstractmethod
|
26
|
+
def startMessage(
|
27
|
+
self,
|
28
|
+
*,
|
29
|
+
print_result: bool,
|
30
|
+
length_tests: int,
|
31
|
+
execution_mode: str,
|
32
|
+
max_workers: int
|
33
|
+
):
|
34
|
+
"""
|
35
|
+
Displays a formatted start message for the test execution session.
|
36
|
+
|
37
|
+
Parameters
|
38
|
+
----------
|
39
|
+
print_result : bool
|
40
|
+
Whether to print the start message.
|
41
|
+
length_tests : int
|
42
|
+
The total number of tests to be executed.
|
43
|
+
execution_mode : str
|
44
|
+
The mode of execution, either "parallel" or "sequential".
|
45
|
+
max_workers : int
|
46
|
+
The number of worker threads/processes for parallel execution.
|
47
|
+
|
48
|
+
Side Effects
|
49
|
+
------------
|
50
|
+
Prints a styled panel with test session information to the console if `print_result` is True.
|
51
|
+
"""
|
52
|
+
pass
|
53
|
+
|
54
|
+
@abstractmethod
|
55
|
+
def finishMessage(
|
56
|
+
self,
|
57
|
+
*,
|
58
|
+
print_result: bool,
|
59
|
+
summary: Dict[str, Any]
|
60
|
+
) -> None:
|
61
|
+
"""
|
62
|
+
Display a summary message for the test suite execution.
|
63
|
+
|
64
|
+
Parameters
|
65
|
+
----------
|
66
|
+
summary : dict
|
67
|
+
Dictionary containing the test suite summary, including keys such as
|
68
|
+
'failed', 'errors', and 'total_time'.
|
69
|
+
|
70
|
+
Notes
|
71
|
+
-----
|
72
|
+
- If `self.print_result` is False, the method returns without displaying anything.
|
73
|
+
- Shows a status icon (✅ for success, ❌ for failure) based on the presence of
|
74
|
+
failures or errors in the test suite.
|
75
|
+
- Formats and prints the message within a styled panel using the `rich` library.
|
76
|
+
"""
|
77
|
+
pass
|
78
|
+
|
79
|
+
@abstractmethod
|
80
|
+
def executePanel(
|
81
|
+
self,
|
82
|
+
*,
|
83
|
+
print_result: bool,
|
84
|
+
flatten_test_suite: list,
|
85
|
+
callable: callable
|
86
|
+
):
|
87
|
+
"""
|
88
|
+
Executes a test suite panel with optional live console output.
|
89
|
+
|
90
|
+
Parameters
|
91
|
+
----------
|
92
|
+
print_result : bool
|
93
|
+
If True, displays a running message panel while executing the test suite.
|
94
|
+
flatten_test_suite : list
|
95
|
+
The flattened list of test cases or test suite items to be executed.
|
96
|
+
callable : callable
|
97
|
+
The function or method to execute the test suite.
|
98
|
+
|
99
|
+
Returns
|
100
|
+
-------
|
101
|
+
Any
|
102
|
+
The result returned by the provided callable after execution.
|
103
|
+
|
104
|
+
Notes
|
105
|
+
-----
|
106
|
+
This method manages the display of a running message panel using the Rich library,
|
107
|
+
depending on whether debugging is enabled in the test suite and whether results should be printed.
|
108
|
+
If debugging or dump calls are detected in the test code, a live console is used to display
|
109
|
+
real-time updates. Otherwise, a static panel is shown before executing the test suite.
|
110
|
+
"""
|
111
|
+
pass
|
112
|
+
|
113
|
+
@abstractmethod
|
114
|
+
def linkWebReport(
|
115
|
+
self,
|
116
|
+
path: str
|
117
|
+
):
|
118
|
+
"""
|
119
|
+
Prints an elegant invitation to view the test results, with an underlined path.
|
120
|
+
|
121
|
+
Parameters
|
122
|
+
----------
|
123
|
+
path : str or Path
|
124
|
+
The path to the test results report.
|
125
|
+
"""
|
126
|
+
pass
|
127
|
+
|
128
|
+
@abstractmethod
|
129
|
+
def summaryTable(
|
130
|
+
self,
|
131
|
+
summary: Dict[str, Any]
|
132
|
+
) -> None:
|
133
|
+
"""
|
134
|
+
Prints a summary table of test results using the Rich library.
|
135
|
+
|
136
|
+
Parameters
|
137
|
+
----------
|
138
|
+
summary : dict
|
139
|
+
Dictionary with the test summary data. Must contain the following keys:
|
140
|
+
total_tests : int
|
141
|
+
Total number of tests executed.
|
142
|
+
passed : int
|
143
|
+
Number of tests that passed.
|
144
|
+
failed : int
|
145
|
+
Number of tests that failed.
|
146
|
+
errors : int
|
147
|
+
Number of tests that had errors.
|
148
|
+
skipped : int
|
149
|
+
Number of tests that were skipped.
|
150
|
+
total_time : float
|
151
|
+
Total duration of the test execution in seconds.
|
152
|
+
success_rate : float
|
153
|
+
Percentage of tests that passed.
|
154
|
+
|
155
|
+
Returns
|
156
|
+
-------
|
157
|
+
None
|
158
|
+
"""
|
159
|
+
pass
|
160
|
+
|
161
|
+
@abstractmethod
|
162
|
+
def displayResults(
|
163
|
+
self,
|
164
|
+
*,
|
165
|
+
print_result: bool,
|
166
|
+
summary: Dict[str, Any]
|
167
|
+
) -> None:
|
168
|
+
"""
|
169
|
+
Display the results of the test execution, including a summary table and detailed
|
170
|
+
information about failed or errored tests grouped by their test classes.
|
171
|
+
|
172
|
+
Parameters
|
173
|
+
----------
|
174
|
+
summary : dict
|
175
|
+
Dictionary containing the summary of the test execution, including test details,
|
176
|
+
statuses, and execution times.
|
177
|
+
|
178
|
+
Notes
|
179
|
+
-----
|
180
|
+
- Prints a summary table of the test results.
|
181
|
+
- Groups failed and errored tests by their test class and displays them in a structured
|
182
|
+
format using panels.
|
183
|
+
- For each failed or errored test, displays the traceback in a syntax-highlighted panel
|
184
|
+
with additional metadata such as the test method name and execution time.
|
185
|
+
- Uses different icons and border colors to distinguish between failed and errored tests.
|
186
|
+
- Calls a finishing message method after displaying all results.
|
187
|
+
"""
|
188
|
+
pass
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from abc import ABC, abstractmethod
|
2
2
|
from typing import Any, Dict, List, Optional
|
3
|
+
from orionis.services.system.workers import Workers
|
3
4
|
from orionis.test.enums.test_mode import ExecutionMode
|
4
5
|
|
5
6
|
class IUnitTest(ABC):
|
@@ -7,11 +8,12 @@ class IUnitTest(ABC):
|
|
7
8
|
@abstractmethod
|
8
9
|
def configure(
|
9
10
|
self,
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
*,
|
12
|
+
verbosity: int = 2,
|
13
|
+
execution_mode: str | ExecutionMode = ExecutionMode.SEQUENTIAL,
|
14
|
+
max_workers: int = Workers().calculate(),
|
15
|
+
fail_fast: bool = False,
|
16
|
+
print_result: bool = True,
|
15
17
|
throw_exception: bool = False,
|
16
18
|
persistent: bool = False,
|
17
19
|
persistent_driver: str = 'sqlite',
|
@@ -49,8 +51,9 @@ class IUnitTest(ABC):
|
|
49
51
|
@abstractmethod
|
50
52
|
def discoverTestsInFolder(
|
51
53
|
self,
|
52
|
-
|
54
|
+
*,
|
53
55
|
base_path: str = "tests",
|
56
|
+
folder_path: str,
|
54
57
|
pattern: str = "test_*.py",
|
55
58
|
test_name_pattern: Optional[str] = None,
|
56
59
|
tags: Optional[List[str]] = None
|
@@ -86,7 +89,12 @@ class IUnitTest(ABC):
|
|
86
89
|
pass
|
87
90
|
|
88
91
|
@abstractmethod
|
89
|
-
def discoverTestsInModule(
|
92
|
+
def discoverTestsInModule(
|
93
|
+
self,
|
94
|
+
*,
|
95
|
+
module_name: str,
|
96
|
+
test_name_pattern: Optional[str] = None
|
97
|
+
):
|
90
98
|
"""
|
91
99
|
Discovers and loads tests from a specified module, optionally filtering by a test name pattern, and adds them to the test suite.
|
92
100
|
|
@@ -110,7 +118,9 @@ class IUnitTest(ABC):
|
|
110
118
|
pass
|
111
119
|
|
112
120
|
@abstractmethod
|
113
|
-
def run(
|
121
|
+
def run(
|
122
|
+
self
|
123
|
+
) -> Dict[str, Any]:
|
114
124
|
"""
|
115
125
|
Executes the test suite and processes the results.
|
116
126
|
|
@@ -134,7 +144,9 @@ class IUnitTest(ABC):
|
|
134
144
|
pass
|
135
145
|
|
136
146
|
@abstractmethod
|
137
|
-
def getTestNames(
|
147
|
+
def getTestNames(
|
148
|
+
self
|
149
|
+
) -> List[str]:
|
138
150
|
"""
|
139
151
|
Get a list of test names (unique identifiers) from the test suite.
|
140
152
|
|
@@ -146,7 +158,9 @@ class IUnitTest(ABC):
|
|
146
158
|
pass
|
147
159
|
|
148
160
|
@abstractmethod
|
149
|
-
def getTestCount(
|
161
|
+
def getTestCount(
|
162
|
+
self
|
163
|
+
) -> int:
|
150
164
|
"""
|
151
165
|
Returns the total number of test cases in the test suite.
|
152
166
|
|
@@ -158,7 +172,9 @@ class IUnitTest(ABC):
|
|
158
172
|
pass
|
159
173
|
|
160
174
|
@abstractmethod
|
161
|
-
def clearTests(
|
175
|
+
def clearTests(
|
176
|
+
self
|
177
|
+
) -> None:
|
162
178
|
"""
|
163
179
|
Clear all tests from the current test suite.
|
164
180
|
|
@@ -167,7 +183,9 @@ class IUnitTest(ABC):
|
|
167
183
|
pass
|
168
184
|
|
169
185
|
@abstractmethod
|
170
|
-
def getResult(
|
186
|
+
def getResult(
|
187
|
+
self
|
188
|
+
) -> dict:
|
171
189
|
"""
|
172
190
|
Returns the results of the executed test suite.
|
173
191
|
|
@@ -179,7 +197,9 @@ class IUnitTest(ABC):
|
|
179
197
|
pass
|
180
198
|
|
181
199
|
@abstractmethod
|
182
|
-
def getOutputBuffer(
|
200
|
+
def getOutputBuffer(
|
201
|
+
self
|
202
|
+
) -> int:
|
183
203
|
"""
|
184
204
|
Returns the output buffer used for capturing test results.
|
185
205
|
This method returns the internal output buffer that collects the results of the test execution.
|
@@ -191,7 +211,9 @@ class IUnitTest(ABC):
|
|
191
211
|
pass
|
192
212
|
|
193
213
|
@abstractmethod
|
194
|
-
def printOutputBuffer(
|
214
|
+
def printOutputBuffer(
|
215
|
+
self
|
216
|
+
) -> None:
|
195
217
|
"""
|
196
218
|
Prints the contents of the output buffer to the console.
|
197
219
|
This method retrieves the output buffer and prints its contents using the rich console.
|
@@ -199,7 +221,9 @@ class IUnitTest(ABC):
|
|
199
221
|
pass
|
200
222
|
|
201
223
|
@abstractmethod
|
202
|
-
def getErrorBuffer(
|
224
|
+
def getErrorBuffer(
|
225
|
+
self
|
226
|
+
) -> int:
|
203
227
|
"""
|
204
228
|
Returns the error buffer used for capturing test errors.
|
205
229
|
This method returns the internal error buffer that collects any errors encountered during test execution.
|
@@ -211,7 +235,9 @@ class IUnitTest(ABC):
|
|
211
235
|
pass
|
212
236
|
|
213
237
|
@abstractmethod
|
214
|
-
def printErrorBuffer(
|
238
|
+
def printErrorBuffer(
|
239
|
+
self
|
240
|
+
) -> None:
|
215
241
|
"""
|
216
242
|
Prints the contents of the error buffer to the console.
|
217
243
|
This method retrieves the error buffer and prints its contents using the rich console.
|