orionis 0.432.0__py3-none-any.whl → 0.434.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/app.py +17 -0
- orionis/metadata/framework.py +1 -1
- orionis/support/entities/base.py +18 -37
- orionis/support/facades/console.py +3 -9
- orionis/support/facades/dumper.py +3 -9
- orionis/support/facades/logger.py +3 -9
- orionis/support/facades/path_resolver.py +3 -10
- orionis/support/facades/progress_bar.py +3 -10
- orionis/support/facades/testing.py +4 -10
- orionis/support/facades/workers.py +4 -9
- orionis/support/formatter/exceptions/contracts/parser.py +10 -7
- orionis/support/formatter/exceptions/parser.py +28 -26
- orionis/support/formatter/serializer.py +12 -5
- orionis/support/patterns/singleton/meta.py +17 -21
- orionis/support/standard/contracts/std.py +25 -24
- orionis/support/standard/exceptions/value.py +2 -2
- orionis/support/standard/std.py +26 -24
- orionis/support/wrapper/dot_dict.py +16 -51
- orionis/test/cases/asynchronous.py +17 -81
- orionis/test/cases/synchronous.py +17 -73
- orionis/test/contracts/dumper.py +17 -21
- orionis/test/contracts/kernel.py +5 -12
- orionis/test/contracts/logs.py +16 -21
- orionis/test/contracts/printer.py +70 -8
- orionis/test/contracts/render.py +7 -13
- orionis/test/contracts/test_result.py +58 -27
- orionis/test/contracts/unit_test.py +18 -18
- orionis/test/core/unit_test.py +162 -519
- orionis/test/entities/result.py +49 -21
- orionis/test/enums/status.py +11 -17
- orionis/test/exceptions/config.py +4 -8
- orionis/test/exceptions/failure.py +2 -18
- orionis/test/exceptions/persistence.py +4 -8
- orionis/test/exceptions/runtime.py +4 -8
- orionis/test/exceptions/value.py +5 -13
- orionis/test/kernel.py +14 -42
- orionis/test/output/dumper.py +21 -43
- orionis/test/output/printer.py +6 -146
- orionis/test/records/logs.py +57 -121
- orionis/test/validators/base_path.py +8 -6
- orionis/test/validators/execution_mode.py +2 -3
- orionis/test/validators/fail_fast.py +4 -8
- orionis/test/validators/folder_path.py +5 -7
- orionis/test/validators/module_name.py +3 -3
- orionis/test/validators/name_pattern.py +4 -9
- orionis/test/validators/pattern.py +4 -9
- orionis/test/validators/persistent.py +4 -14
- orionis/test/validators/persistent_driver.py +7 -12
- orionis/test/validators/print_result.py +4 -9
- orionis/test/validators/tags.py +6 -7
- orionis/test/validators/throw_exception.py +7 -14
- orionis/test/validators/verbosity.py +15 -5
- orionis/test/validators/web_report.py +6 -10
- orionis/test/validators/workers.py +9 -4
- orionis/test/view/render.py +9 -26
- {orionis-0.432.0.dist-info → orionis-0.434.0.dist-info}/METADATA +1 -1
- {orionis-0.432.0.dist-info → orionis-0.434.0.dist-info}/RECORD +76 -75
- tests/support/entities/mock_dataclass.py +16 -10
- tests/support/entities/test_base.py +6 -14
- tests/support/patterns/singleton/test_patterns_singleton.py +7 -8
- tests/support/standard/test_services_std.py +113 -37
- tests/support/wrapper/test_services_wrapper_docdict.py +25 -40
- tests/testing/cases/test_testing_asynchronous.py +14 -14
- tests/testing/cases/test_testing_synchronous.py +12 -14
- tests/testing/entities/test_testing_result.py +12 -51
- tests/testing/enums/test_testing_status.py +8 -13
- tests/testing/output/test_testing_dumper.py +3 -6
- tests/testing/output/test_testing_printer.py +5 -5
- tests/testing/records/test_testing_records.py +16 -26
- tests/testing/test_testing_unit.py +8 -94
- tests/testing/validators/test_testing_validators.py +55 -112
- tests/testing/view/test_render.py +4 -5
- {orionis-0.432.0.dist-info → orionis-0.434.0.dist-info}/WHEEL +0 -0
- {orionis-0.432.0.dist-info → orionis-0.434.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.432.0.dist-info → orionis-0.434.0.dist-info}/top_level.txt +0 -0
- {orionis-0.432.0.dist-info → orionis-0.434.0.dist-info}/zip-safe +0 -0
orionis/test/entities/result.py
CHANGED
|
@@ -5,29 +5,57 @@ from orionis.test.enums import TestStatus
|
|
|
5
5
|
@dataclass(frozen=True, kw_only=True)
|
|
6
6
|
class TestResult:
|
|
7
7
|
"""
|
|
8
|
-
|
|
8
|
+
Represents the outcome of a test execution.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
Parameters
|
|
11
|
+
----------
|
|
12
|
+
id : Any
|
|
13
|
+
Unique identifier for the test result.
|
|
14
|
+
name : str
|
|
15
|
+
Name of the test.
|
|
16
|
+
status : TestStatus
|
|
17
|
+
Status of the test execution (e.g., passed, failed).
|
|
18
|
+
execution_time : float
|
|
19
|
+
Time taken to execute the test, in seconds.
|
|
20
|
+
error_message : Optional[str], optional
|
|
21
|
+
Error message if the test failed, otherwise None.
|
|
22
|
+
traceback : Optional[str], optional
|
|
23
|
+
Traceback information if an error occurred, otherwise None.
|
|
24
|
+
class_name : Optional[str], optional
|
|
25
|
+
Name of the class containing the test, if applicable.
|
|
26
|
+
method : Optional[str], optional
|
|
27
|
+
Name of the method representing the test, if applicable.
|
|
28
|
+
module : Optional[str], optional
|
|
29
|
+
Name of the module containing the test, if applicable.
|
|
30
|
+
file_path : Optional[str], optional
|
|
31
|
+
Path to the file containing the test, if applicable.
|
|
32
|
+
doc_string : Optional[str], optional
|
|
33
|
+
Docstring of the test, if applicable.
|
|
15
34
|
|
|
16
|
-
Attributes
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
Attributes
|
|
36
|
+
----------
|
|
37
|
+
id : Any
|
|
38
|
+
Unique identifier for the test result.
|
|
39
|
+
name : str
|
|
40
|
+
Name of the test.
|
|
41
|
+
status : TestStatus
|
|
42
|
+
Status of the test execution.
|
|
43
|
+
execution_time : float
|
|
44
|
+
Time taken to execute the test.
|
|
45
|
+
error_message : Optional[str]
|
|
46
|
+
Error message if the test failed.
|
|
47
|
+
traceback : Optional[str]
|
|
48
|
+
Traceback information if an error occurred.
|
|
49
|
+
class_name : Optional[str]
|
|
50
|
+
Name of the class containing the test.
|
|
51
|
+
method : Optional[str]
|
|
52
|
+
Name of the method representing the test.
|
|
53
|
+
module : Optional[str]
|
|
54
|
+
Name of the module containing the test.
|
|
55
|
+
file_path : Optional[str]
|
|
56
|
+
Path to the file containing the test.
|
|
57
|
+
doc_string : Optional[str]
|
|
58
|
+
Docstring of the test.
|
|
31
59
|
"""
|
|
32
60
|
|
|
33
61
|
# Unique identifier for the test result
|
orionis/test/enums/status.py
CHANGED
|
@@ -2,26 +2,20 @@ from enum import Enum, auto
|
|
|
2
2
|
|
|
3
3
|
class TestStatus(Enum):
|
|
4
4
|
"""
|
|
5
|
-
|
|
6
|
-
An enumeration representing the possible statuses that a test can have during its execution.
|
|
5
|
+
Enumeration of possible statuses for a test during execution.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
----------
|
|
10
|
-
PASSED : auto()
|
|
11
|
-
The test completed successfully without any errors or failures.
|
|
12
|
-
FAILED : auto()
|
|
13
|
-
The test ran to completion but did not produce the expected results.
|
|
14
|
-
ERRORED : auto()
|
|
15
|
-
An unexpected error occurred during the execution of the test, preventing it from completing.
|
|
16
|
-
SKIPPED : auto()
|
|
17
|
-
The test was intentionally not executed, typically due to configuration or conditional logic.
|
|
18
|
-
|
|
19
|
-
Returns
|
|
7
|
+
Members
|
|
20
8
|
-------
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
PASSED : enum
|
|
10
|
+
Indicates the test completed successfully without errors or failures.
|
|
11
|
+
FAILED : enum
|
|
12
|
+
Indicates the test completed but did not produce the expected results.
|
|
13
|
+
ERRORED : enum
|
|
14
|
+
Indicates an unexpected error occurred during test execution.
|
|
15
|
+
SKIPPED : enum
|
|
16
|
+
Indicates the test was intentionally not executed.
|
|
23
17
|
"""
|
|
24
18
|
PASSED = auto() # Test executed successfully
|
|
25
19
|
FAILED = auto() # Test executed but failed
|
|
26
20
|
ERRORED = auto() # Error occurred during test execution
|
|
27
|
-
SKIPPED = auto() # Test was intentionally skipped
|
|
21
|
+
SKIPPED = auto() # Test was intentionally skipped
|
|
@@ -2,26 +2,22 @@ class OrionisTestConfigException(Exception):
|
|
|
2
2
|
|
|
3
3
|
def __init__(self, msg: str):
|
|
4
4
|
"""
|
|
5
|
-
|
|
5
|
+
Initialize the OrionisTestConfigException.
|
|
6
6
|
|
|
7
7
|
Parameters
|
|
8
8
|
----------
|
|
9
9
|
msg : str
|
|
10
|
-
|
|
10
|
+
The error message describing the cause of the exception.
|
|
11
11
|
"""
|
|
12
|
-
|
|
13
|
-
# Call the base Exception class constructor with the message
|
|
14
12
|
super().__init__(msg)
|
|
15
13
|
|
|
16
14
|
def __str__(self) -> str:
|
|
17
15
|
"""
|
|
18
|
-
|
|
16
|
+
Return the exception message as a string.
|
|
19
17
|
|
|
20
18
|
Returns
|
|
21
19
|
-------
|
|
22
20
|
str
|
|
23
|
-
The error message provided during
|
|
21
|
+
The error message provided during initialization.
|
|
24
22
|
"""
|
|
25
|
-
|
|
26
|
-
# Return the first argument as the exception message
|
|
27
23
|
return str(self.args[0])
|
|
@@ -4,11 +4,7 @@ class OrionisTestFailureException(Exception):
|
|
|
4
4
|
|
|
5
5
|
def __init__(self, result: unittest.TestResult):
|
|
6
6
|
"""
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
This constructor extracts information from the provided unittest.TestResult object,
|
|
10
|
-
including the IDs of tests that failed or encountered errors. It then formats a summary
|
|
11
|
-
message listing all such tests and passes this message to the base Exception class.
|
|
7
|
+
Initialize the exception with details of failed and errored tests.
|
|
12
8
|
|
|
13
9
|
Parameters
|
|
14
10
|
----------
|
|
@@ -25,18 +21,7 @@ class OrionisTestFailureException(Exception):
|
|
|
25
21
|
List of formatted error messages for each failed or errored test.
|
|
26
22
|
text : str
|
|
27
23
|
Formatted string summarizing all test failures and errors.
|
|
28
|
-
|
|
29
|
-
Returns
|
|
30
|
-
-------
|
|
31
|
-
None
|
|
32
|
-
This method does not return a value. It initializes the exception instance.
|
|
33
|
-
|
|
34
|
-
Raises
|
|
35
|
-
------
|
|
36
|
-
OrionisTestFailureException
|
|
37
|
-
Raised when there are failed or errored tests, with a summary message.
|
|
38
24
|
"""
|
|
39
|
-
|
|
40
25
|
# Collect IDs of failed tests
|
|
41
26
|
failed_tests = [test.id() for test, _ in result.failures]
|
|
42
27
|
|
|
@@ -61,13 +46,12 @@ class OrionisTestFailureException(Exception):
|
|
|
61
46
|
|
|
62
47
|
def __str__(self) -> str:
|
|
63
48
|
"""
|
|
64
|
-
|
|
49
|
+
Return a formatted string describing the exception.
|
|
65
50
|
|
|
66
51
|
Returns
|
|
67
52
|
-------
|
|
68
53
|
str
|
|
69
54
|
The summary message containing the number and details of failed and errored tests.
|
|
70
55
|
"""
|
|
71
|
-
|
|
72
56
|
# Return the first argument passed to the exception as a string
|
|
73
57
|
return str(self.args[0])
|
|
@@ -2,26 +2,22 @@ class OrionisTestPersistenceError(Exception):
|
|
|
2
2
|
|
|
3
3
|
def __init__(self, msg: str):
|
|
4
4
|
"""
|
|
5
|
-
|
|
5
|
+
Initialize the OrionisTestPersistenceError with an error message.
|
|
6
6
|
|
|
7
7
|
Parameters
|
|
8
8
|
----------
|
|
9
9
|
msg : str
|
|
10
|
-
|
|
10
|
+
The error message describing the cause of the exception.
|
|
11
11
|
"""
|
|
12
|
-
|
|
13
|
-
# Call the base Exception class constructor with the message
|
|
14
12
|
super().__init__(msg)
|
|
15
13
|
|
|
16
14
|
def __str__(self) -> str:
|
|
17
15
|
"""
|
|
18
|
-
|
|
16
|
+
Return the string representation of the exception message.
|
|
19
17
|
|
|
20
18
|
Returns
|
|
21
19
|
-------
|
|
22
20
|
str
|
|
23
|
-
The error message
|
|
21
|
+
The error message associated with the exception.
|
|
24
22
|
"""
|
|
25
|
-
|
|
26
|
-
# Return the first argument passed to the exception as a string
|
|
27
23
|
return str(self.args[0])
|
|
@@ -2,26 +2,22 @@ class OrionisTestRuntimeError(Exception):
|
|
|
2
2
|
|
|
3
3
|
def __init__(self, msg: str):
|
|
4
4
|
"""
|
|
5
|
-
|
|
5
|
+
Initialize the OrionisTestRuntimeError with a specific error message.
|
|
6
6
|
|
|
7
7
|
Parameters
|
|
8
8
|
----------
|
|
9
9
|
msg : str
|
|
10
|
-
|
|
10
|
+
The error message describing the cause of the exception.
|
|
11
11
|
"""
|
|
12
|
-
|
|
13
|
-
# Call the base class constructor with the error message
|
|
14
12
|
super().__init__(msg)
|
|
15
13
|
|
|
16
14
|
def __str__(self) -> str:
|
|
17
15
|
"""
|
|
18
|
-
|
|
16
|
+
Return the string representation of the exception.
|
|
19
17
|
|
|
20
18
|
Returns
|
|
21
19
|
-------
|
|
22
20
|
str
|
|
23
|
-
The error message provided during
|
|
21
|
+
The error message provided during initialization.
|
|
24
22
|
"""
|
|
25
|
-
|
|
26
|
-
# Return the error message stored in the first argument
|
|
27
23
|
return str(self.args[0])
|
orionis/test/exceptions/value.py
CHANGED
|
@@ -2,30 +2,22 @@ class OrionisTestValueError(Exception):
|
|
|
2
2
|
|
|
3
3
|
def __init__(self, msg: str):
|
|
4
4
|
"""
|
|
5
|
-
|
|
5
|
+
Initialize the OrionisTestValueError exception.
|
|
6
6
|
|
|
7
7
|
Parameters
|
|
8
8
|
----------
|
|
9
9
|
msg : str
|
|
10
|
-
|
|
10
|
+
The error message describing the cause of the exception.
|
|
11
11
|
"""
|
|
12
|
-
|
|
13
|
-
# Call the base class constructor with the error message
|
|
14
12
|
super().__init__(msg)
|
|
15
13
|
|
|
16
14
|
def __str__(self) -> str:
|
|
17
15
|
"""
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
This method retrieves the error message provided during initialization
|
|
21
|
-
and returns it as a string. It ensures that when the exception is
|
|
22
|
-
converted to a string, the descriptive message is displayed.
|
|
16
|
+
Return the string representation of the exception.
|
|
23
17
|
|
|
24
18
|
Returns
|
|
25
19
|
-------
|
|
26
20
|
str
|
|
27
|
-
The
|
|
21
|
+
The error message associated with this exception.
|
|
28
22
|
"""
|
|
29
|
-
|
|
30
|
-
# Return the error message stored in the first argument
|
|
31
|
-
return str(self.args[0])
|
|
23
|
+
return str(self.args[0])
|
orionis/test/kernel.py
CHANGED
|
@@ -21,29 +21,22 @@ class TestKernel(ITestKernel):
|
|
|
21
21
|
Parameters
|
|
22
22
|
----------
|
|
23
23
|
app : IApplication
|
|
24
|
-
|
|
24
|
+
Application instance implementing the IApplication contract.
|
|
25
25
|
|
|
26
26
|
Raises
|
|
27
27
|
------
|
|
28
28
|
OrionisTestConfigException
|
|
29
29
|
If the provided app is not an instance of IApplication.
|
|
30
30
|
"""
|
|
31
|
-
|
|
32
|
-
# Validate that the app is an instance of IApplication
|
|
33
31
|
if not isinstance(app, IApplication):
|
|
34
32
|
raise OrionisTestConfigException(
|
|
35
33
|
f"Failed to initialize TestKernel: expected IApplication, got {type(app).__module__}.{type(app).__name__}."
|
|
36
34
|
)
|
|
37
35
|
|
|
38
|
-
# Load testing configuration from the application
|
|
39
36
|
self.__config = Testing(**app.config('testing'))
|
|
40
|
-
|
|
41
|
-
# Create and configure the unit test instance
|
|
42
37
|
self.__unit_test: IUnitTest = app.make('core.orionis.testing')
|
|
43
38
|
self.__unit_test._UnitTest__app = app
|
|
44
39
|
self.__unit_test._UnitTest__storage = app.path('storage_testing')
|
|
45
|
-
|
|
46
|
-
# Initialize the console for output
|
|
47
40
|
self.__console: IConsole = app.make('core.orionis.console')
|
|
48
41
|
|
|
49
42
|
def __listMatchingFolders(
|
|
@@ -53,52 +46,47 @@ class TestKernel(ITestKernel):
|
|
|
53
46
|
pattern: str
|
|
54
47
|
) -> List[str]:
|
|
55
48
|
"""
|
|
56
|
-
List folders within a
|
|
49
|
+
List folders within a given path containing files matching a pattern.
|
|
57
50
|
|
|
58
51
|
Parameters
|
|
59
52
|
----------
|
|
60
53
|
base_path : Path
|
|
61
|
-
The base directory path for relative
|
|
54
|
+
The base directory path for calculating relative paths.
|
|
62
55
|
custom_path : Path
|
|
63
|
-
The
|
|
56
|
+
The directory path to search for matching files.
|
|
64
57
|
pattern : str
|
|
65
|
-
The filename pattern to match
|
|
58
|
+
The filename pattern to match, supporting '*' and '?' wildcards.
|
|
66
59
|
|
|
67
60
|
Returns
|
|
68
61
|
-------
|
|
69
62
|
List[str]
|
|
70
63
|
List of relative folder paths containing files matching the pattern.
|
|
71
64
|
"""
|
|
72
|
-
|
|
73
|
-
# Compile the pattern into a regex for matching file names
|
|
74
65
|
regex = re.compile('^' + pattern.replace('*', '.*').replace('?', '.') + '$')
|
|
75
66
|
matched_folders = set()
|
|
76
|
-
|
|
77
|
-
# Walk through the directory tree starting at custom_path
|
|
78
67
|
for root, _, files in walk(str(custom_path)):
|
|
79
|
-
|
|
80
|
-
# Check if any file in the current folder matches the pattern
|
|
81
68
|
if any(regex.fullmatch(file) for file in files):
|
|
82
|
-
|
|
83
|
-
# Calculate the relative path from base_path and add to results
|
|
84
69
|
rel_path = Path(root).relative_to(base_path).as_posix()
|
|
85
70
|
matched_folders.add(rel_path)
|
|
86
|
-
|
|
87
|
-
# Return the list of matching folder paths
|
|
88
71
|
return list(matched_folders)
|
|
89
72
|
|
|
90
73
|
def handle(self) -> IUnitTest:
|
|
91
74
|
"""
|
|
92
|
-
Configure and execute
|
|
75
|
+
Configure, discover, and execute unit tests based on the current configuration.
|
|
93
76
|
|
|
94
77
|
Returns
|
|
95
78
|
-------
|
|
96
79
|
IUnitTest
|
|
97
80
|
The configured and executed unit test instance.
|
|
81
|
+
|
|
82
|
+
Raises
|
|
83
|
+
------
|
|
84
|
+
OrionisTestFailureException
|
|
85
|
+
If test execution fails.
|
|
86
|
+
Exception
|
|
87
|
+
If an unexpected error occurs during test execution.
|
|
98
88
|
"""
|
|
99
89
|
try:
|
|
100
|
-
|
|
101
|
-
# Configure the unit test with parameters from the configuration
|
|
102
90
|
self.__unit_test.configure(
|
|
103
91
|
verbosity=self.__config.verbosity,
|
|
104
92
|
execution_mode=self.__config.execution_mode,
|
|
@@ -111,32 +99,21 @@ class TestKernel(ITestKernel):
|
|
|
111
99
|
web_report=self.__config.web_report
|
|
112
100
|
)
|
|
113
101
|
|
|
114
|
-
# Prepare paths and pattern for test discovery
|
|
115
102
|
base_path = (Path.cwd() / self.__config.base_path).resolve()
|
|
116
103
|
folder_path = self.__config.folder_path
|
|
117
104
|
pattern = self.__config.pattern
|
|
118
|
-
|
|
119
|
-
# Set to hold discovered folders
|
|
120
105
|
discovered_folders = set()
|
|
121
106
|
|
|
122
|
-
# Discover folders containing test files according to the configuration
|
|
123
|
-
|
|
124
|
-
# Search all folders under base_path
|
|
125
107
|
if folder_path == '*':
|
|
126
108
|
discovered_folders.update(self.__listMatchingFolders(base_path, base_path, pattern))
|
|
127
|
-
|
|
128
|
-
# Search each custom folder in the list
|
|
129
109
|
elif isinstance(folder_path, list):
|
|
130
110
|
for custom in folder_path:
|
|
131
111
|
custom_path = (base_path / custom).resolve()
|
|
132
112
|
discovered_folders.update(self.__listMatchingFolders(base_path, custom_path, pattern))
|
|
133
|
-
|
|
134
|
-
# Search a single custom folder
|
|
135
113
|
else:
|
|
136
114
|
custom_path = (base_path / folder_path).resolve()
|
|
137
115
|
discovered_folders.update(self.__listMatchingFolders(base_path, custom_path, pattern))
|
|
138
116
|
|
|
139
|
-
# Register discovered folders with the unit test for test discovery
|
|
140
117
|
for folder in discovered_folders:
|
|
141
118
|
self.__unit_test.discoverTestsInFolder(
|
|
142
119
|
folder_path=folder,
|
|
@@ -146,15 +123,10 @@ class TestKernel(ITestKernel):
|
|
|
146
123
|
tags=self.__config.tags or None
|
|
147
124
|
)
|
|
148
125
|
|
|
149
|
-
# Run the unit tests and return the result
|
|
150
126
|
return self.__unit_test.run()
|
|
151
127
|
|
|
152
128
|
except OrionisTestFailureException as e:
|
|
153
|
-
|
|
154
|
-
# Handle test failures and exit with an error message
|
|
155
129
|
self.__console.exitError(f"Test execution failed: {e}")
|
|
156
130
|
|
|
157
131
|
except Exception as e:
|
|
158
|
-
|
|
159
|
-
# Handle unexpected errors and exit with a generic error message
|
|
160
|
-
self.__console.exitError(f"An unexpected error occurred: {e}")
|
|
132
|
+
self.__console.exitError(f"An unexpected error occurred: {e}")
|
orionis/test/output/dumper.py
CHANGED
|
@@ -6,34 +6,16 @@ from orionis.test.contracts.dumper import ITestDumper
|
|
|
6
6
|
|
|
7
7
|
class TestDumper(ITestDumper):
|
|
8
8
|
"""
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- Manage standard output and error streams during debugging dumps.
|
|
15
|
-
- Capture the caller's file and line number for context.
|
|
16
|
-
|
|
17
|
-
Attributes
|
|
18
|
-
----------
|
|
19
|
-
None
|
|
20
|
-
|
|
21
|
-
Methods
|
|
22
|
-
-------
|
|
23
|
-
__isTestCaseClass(value)
|
|
24
|
-
Determines if the given value is an instance of a test case class.
|
|
25
|
-
dd(*args)
|
|
26
|
-
Dumps debugging information using the Debug class.
|
|
27
|
-
dump(*args)
|
|
28
|
-
Dumps debugging information using the Debug class.
|
|
9
|
+
Utility class for debugging and outputting information during test execution.
|
|
10
|
+
|
|
11
|
+
Provides methods to determine if an object is a test case instance, output debugging
|
|
12
|
+
information using the Debug class, manage standard output and error streams, and
|
|
13
|
+
capture the caller's file and line number for context.
|
|
29
14
|
"""
|
|
30
15
|
|
|
31
16
|
def __isTestCaseClass(self, value) -> bool:
|
|
32
17
|
"""
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
This method checks if the given object is an instance of either AsyncTestCase or SyncTestCase,
|
|
36
|
-
which are the supported test case base classes in the Orionis testing framework.
|
|
18
|
+
Check if the provided value is an instance of a recognized test case class.
|
|
37
19
|
|
|
38
20
|
Parameters
|
|
39
21
|
----------
|
|
@@ -43,8 +25,8 @@ class TestDumper(ITestDumper):
|
|
|
43
25
|
Returns
|
|
44
26
|
-------
|
|
45
27
|
bool
|
|
46
|
-
|
|
47
|
-
|
|
28
|
+
True if `value` is an instance of AsyncTestCase, SyncTestCase, unittest.TestCase,
|
|
29
|
+
or unittest.IsolatedAsyncioTestCase. False otherwise or if an import error occurs.
|
|
48
30
|
"""
|
|
49
31
|
|
|
50
32
|
# If the value is None, it cannot be a test case instance.
|
|
@@ -76,23 +58,21 @@ class TestDumper(ITestDumper):
|
|
|
76
58
|
|
|
77
59
|
def dd(self, *args) -> None:
|
|
78
60
|
"""
|
|
79
|
-
|
|
61
|
+
Output debugging information and halt further execution.
|
|
80
62
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
occurs during the dumping process.
|
|
63
|
+
Captures the caller's file and line number for context. Temporarily redirects
|
|
64
|
+
standard output and error streams to ensure correct display. If the first argument
|
|
65
|
+
is a recognized test case instance, it is skipped in the output. Raises a custom
|
|
66
|
+
runtime error if dumping fails.
|
|
86
67
|
|
|
87
68
|
Parameters
|
|
88
69
|
----------
|
|
89
70
|
*args : tuple
|
|
90
|
-
|
|
71
|
+
Objects to be dumped.
|
|
91
72
|
|
|
92
73
|
Returns
|
|
93
74
|
-------
|
|
94
75
|
None
|
|
95
|
-
This method does not return any value. It outputs debug information and may halt execution.
|
|
96
76
|
"""
|
|
97
77
|
|
|
98
78
|
# If no arguments are provided, exit the method early.
|
|
@@ -136,23 +116,21 @@ class TestDumper(ITestDumper):
|
|
|
136
116
|
|
|
137
117
|
def dump(self, *args) -> None:
|
|
138
118
|
"""
|
|
139
|
-
|
|
119
|
+
Output debugging information.
|
|
140
120
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
occurs during the dumping process.
|
|
121
|
+
Captures the caller's file and line number for context. Temporarily redirects
|
|
122
|
+
standard output and error streams to ensure correct display. If the first argument
|
|
123
|
+
is a recognized test case instance, it is skipped in the output. Raises a custom
|
|
124
|
+
runtime error if dumping fails.
|
|
146
125
|
|
|
147
126
|
Parameters
|
|
148
127
|
----------
|
|
149
128
|
*args : tuple
|
|
150
|
-
|
|
129
|
+
Objects to be dumped.
|
|
151
130
|
|
|
152
131
|
Returns
|
|
153
132
|
-------
|
|
154
133
|
None
|
|
155
|
-
This method does not return any value. It outputs debug information.
|
|
156
134
|
"""
|
|
157
135
|
|
|
158
136
|
# If no arguments are provided, exit the method early.
|
|
@@ -192,4 +170,4 @@ class TestDumper(ITestDumper):
|
|
|
192
170
|
|
|
193
171
|
# Restore the original stdout and stderr
|
|
194
172
|
sys.stdout = original_stdout
|
|
195
|
-
sys.stderr = original_stderr
|
|
173
|
+
sys.stderr = original_stderr
|