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
|
@@ -3,86 +3,87 @@ from typing import Any, Dict
|
|
|
3
3
|
|
|
4
4
|
class IStdClass(ABC):
|
|
5
5
|
"""
|
|
6
|
-
|
|
6
|
+
Abstract base class for a dynamic object that allows arbitrary attribute assignment,
|
|
7
7
|
similar to PHP's stdClass.
|
|
8
8
|
|
|
9
|
-
Implementations
|
|
9
|
+
Implementations must support dynamic attribute management and provide methods for
|
|
10
|
+
representation, comparison, serialization, and attribute manipulation.
|
|
10
11
|
"""
|
|
11
12
|
|
|
12
13
|
@abstractmethod
|
|
13
14
|
def __init__(self, **kwargs: Any) -> None:
|
|
14
15
|
"""
|
|
15
|
-
|
|
16
|
+
Initialize the object with optional attributes.
|
|
16
17
|
|
|
17
18
|
Parameters
|
|
18
19
|
----------
|
|
19
|
-
kwargs : Any
|
|
20
|
-
|
|
20
|
+
**kwargs : Any
|
|
21
|
+
Arbitrary keyword arguments to set as initial attributes.
|
|
21
22
|
"""
|
|
22
23
|
pass
|
|
23
24
|
|
|
24
25
|
@abstractmethod
|
|
25
26
|
def __repr__(self) -> str:
|
|
26
27
|
"""
|
|
27
|
-
|
|
28
|
+
Return an unambiguous string representation of the object.
|
|
28
29
|
|
|
29
30
|
Returns
|
|
30
31
|
-------
|
|
31
32
|
str
|
|
32
|
-
|
|
33
|
+
String representation suitable for debugging and object recreation.
|
|
33
34
|
"""
|
|
34
35
|
pass
|
|
35
36
|
|
|
36
37
|
@abstractmethod
|
|
37
38
|
def __str__(self) -> str:
|
|
38
39
|
"""
|
|
39
|
-
|
|
40
|
+
Return a readable string representation of the object.
|
|
40
41
|
|
|
41
42
|
Returns
|
|
42
43
|
-------
|
|
43
44
|
str
|
|
44
|
-
|
|
45
|
+
Human-readable string displaying the object's attributes.
|
|
45
46
|
"""
|
|
46
47
|
pass
|
|
47
48
|
|
|
48
49
|
@abstractmethod
|
|
49
50
|
def __eq__(self, other: Any) -> bool:
|
|
50
51
|
"""
|
|
51
|
-
|
|
52
|
+
Compare this object with another for equality based on attributes.
|
|
52
53
|
|
|
53
54
|
Parameters
|
|
54
55
|
----------
|
|
55
56
|
other : Any
|
|
56
|
-
|
|
57
|
+
Object to compare against.
|
|
57
58
|
|
|
58
59
|
Returns
|
|
59
60
|
-------
|
|
60
61
|
bool
|
|
61
|
-
True if both objects have
|
|
62
|
+
True if both objects have identical attributes and values, False otherwise.
|
|
62
63
|
"""
|
|
63
64
|
pass
|
|
64
65
|
|
|
65
66
|
@abstractmethod
|
|
66
67
|
def toDict(self) -> Dict[str, Any]:
|
|
67
68
|
"""
|
|
68
|
-
|
|
69
|
+
Convert the object's attributes to a dictionary.
|
|
69
70
|
|
|
70
71
|
Returns
|
|
71
72
|
-------
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
dict of str to Any
|
|
74
|
+
Dictionary containing the object's attribute names and values.
|
|
74
75
|
"""
|
|
75
76
|
pass
|
|
76
77
|
|
|
77
78
|
@abstractmethod
|
|
78
79
|
def update(self, **kwargs: Any) -> None:
|
|
79
80
|
"""
|
|
80
|
-
|
|
81
|
+
Update the object's attributes with the provided key-value pairs.
|
|
81
82
|
|
|
82
83
|
Parameters
|
|
83
84
|
----------
|
|
84
|
-
kwargs : Any
|
|
85
|
-
|
|
85
|
+
**kwargs : Any
|
|
86
|
+
Arbitrary keyword arguments to update or add as attributes.
|
|
86
87
|
|
|
87
88
|
Raises
|
|
88
89
|
------
|
|
@@ -94,7 +95,7 @@ class IStdClass(ABC):
|
|
|
94
95
|
@abstractmethod
|
|
95
96
|
def remove(self, *attributes: str) -> None:
|
|
96
97
|
"""
|
|
97
|
-
|
|
98
|
+
Remove one or more attributes from the object.
|
|
98
99
|
|
|
99
100
|
Parameters
|
|
100
101
|
----------
|
|
@@ -104,7 +105,7 @@ class IStdClass(ABC):
|
|
|
104
105
|
Raises
|
|
105
106
|
------
|
|
106
107
|
AttributeError
|
|
107
|
-
If any
|
|
108
|
+
If any specified attribute does not exist.
|
|
108
109
|
"""
|
|
109
110
|
pass
|
|
110
111
|
|
|
@@ -112,16 +113,16 @@ class IStdClass(ABC):
|
|
|
112
113
|
@abstractmethod
|
|
113
114
|
def fromDict(cls, dictionary: Dict[str, Any]) -> 'IStdClass':
|
|
114
115
|
"""
|
|
115
|
-
|
|
116
|
+
Create an instance from a dictionary of attributes.
|
|
116
117
|
|
|
117
118
|
Parameters
|
|
118
119
|
----------
|
|
119
|
-
dictionary :
|
|
120
|
-
Dictionary
|
|
120
|
+
dictionary : dict of str to Any
|
|
121
|
+
Dictionary containing attribute names and values.
|
|
121
122
|
|
|
122
123
|
Returns
|
|
123
124
|
-------
|
|
124
125
|
IStdClass
|
|
125
|
-
|
|
126
|
+
New instance with attributes set from the dictionary.
|
|
126
127
|
"""
|
|
127
128
|
pass
|
|
@@ -5,7 +5,7 @@ class OrionisStdValueException(Exception):
|
|
|
5
5
|
Parameters
|
|
6
6
|
----------
|
|
7
7
|
msg : str
|
|
8
|
-
|
|
8
|
+
The error message that describes the reason for the exception.
|
|
9
9
|
"""
|
|
10
10
|
super().__init__(msg)
|
|
11
11
|
|
|
@@ -14,6 +14,6 @@ class OrionisStdValueException(Exception):
|
|
|
14
14
|
Returns
|
|
15
15
|
-------
|
|
16
16
|
str
|
|
17
|
-
|
|
17
|
+
The error message associated with this exception.
|
|
18
18
|
"""
|
|
19
19
|
return str(self.args[0])
|
orionis/support/standard/std.py
CHANGED
|
@@ -3,56 +3,59 @@ from orionis.support.standard.exceptions import OrionisStdValueException
|
|
|
3
3
|
|
|
4
4
|
class StdClass(IStdClass):
|
|
5
5
|
"""
|
|
6
|
-
A dynamic class
|
|
7
|
-
|
|
6
|
+
A dynamic class for storing arbitrary attributes, similar to PHP's stdClass.
|
|
7
|
+
|
|
8
|
+
Attributes
|
|
9
|
+
----------
|
|
10
|
+
Any attribute can be dynamically set via keyword arguments or the `update` method.
|
|
8
11
|
"""
|
|
9
12
|
|
|
10
13
|
def __init__(self, **kwargs):
|
|
11
14
|
"""
|
|
12
|
-
|
|
15
|
+
Initialize a StdClass instance with optional attributes.
|
|
13
16
|
|
|
14
17
|
Parameters
|
|
15
18
|
----------
|
|
16
|
-
kwargs : dict
|
|
17
|
-
|
|
19
|
+
**kwargs : dict, optional
|
|
20
|
+
Arbitrary keyword arguments to set as attributes.
|
|
18
21
|
"""
|
|
19
22
|
self.update(**kwargs)
|
|
20
23
|
|
|
21
24
|
def __repr__(self):
|
|
22
25
|
"""
|
|
23
|
-
|
|
26
|
+
Return an unambiguous string representation of the object.
|
|
24
27
|
|
|
25
28
|
Returns
|
|
26
29
|
-------
|
|
27
30
|
str
|
|
28
|
-
|
|
31
|
+
String representation suitable for debugging.
|
|
29
32
|
"""
|
|
30
33
|
return f"{self.__class__.__name__}({self.__dict__})"
|
|
31
34
|
|
|
32
35
|
def __str__(self):
|
|
33
36
|
"""
|
|
34
|
-
|
|
37
|
+
Return a readable string representation of the object.
|
|
35
38
|
|
|
36
39
|
Returns
|
|
37
40
|
-------
|
|
38
41
|
str
|
|
39
|
-
|
|
42
|
+
String showing the object's attributes.
|
|
40
43
|
"""
|
|
41
44
|
return str(self.__dict__)
|
|
42
45
|
|
|
43
46
|
def __eq__(self, other):
|
|
44
47
|
"""
|
|
45
|
-
|
|
48
|
+
Compare two StdClass objects for equality based on their attributes.
|
|
46
49
|
|
|
47
50
|
Parameters
|
|
48
51
|
----------
|
|
49
52
|
other : object
|
|
50
|
-
|
|
53
|
+
Object to compare with.
|
|
51
54
|
|
|
52
55
|
Returns
|
|
53
56
|
-------
|
|
54
57
|
bool
|
|
55
|
-
True if both objects have the same attributes and values.
|
|
58
|
+
True if both objects have the same attributes and values, False otherwise.
|
|
56
59
|
"""
|
|
57
60
|
if not isinstance(other, StdClass):
|
|
58
61
|
return False
|
|
@@ -60,30 +63,29 @@ class StdClass(IStdClass):
|
|
|
60
63
|
|
|
61
64
|
def toDict(self):
|
|
62
65
|
"""
|
|
63
|
-
|
|
66
|
+
Convert the object's attributes to a dictionary.
|
|
64
67
|
|
|
65
68
|
Returns
|
|
66
69
|
-------
|
|
67
70
|
dict
|
|
68
|
-
A
|
|
71
|
+
A shallow copy of the object's attributes.
|
|
69
72
|
"""
|
|
70
|
-
|
|
71
73
|
# Return a copy to avoid external modifications
|
|
72
74
|
return self.__dict__.copy()
|
|
73
75
|
|
|
74
76
|
def update(self, **kwargs):
|
|
75
77
|
"""
|
|
76
|
-
|
|
78
|
+
Update the object's attributes dynamically.
|
|
77
79
|
|
|
78
80
|
Parameters
|
|
79
81
|
----------
|
|
80
|
-
kwargs : dict
|
|
81
|
-
Key-value pairs to update attributes.
|
|
82
|
+
**kwargs : dict
|
|
83
|
+
Key-value pairs to update or add as attributes.
|
|
82
84
|
|
|
83
85
|
Raises
|
|
84
86
|
------
|
|
85
87
|
OrionisStdValueException
|
|
86
|
-
If an attribute name is
|
|
88
|
+
If an attribute name is reserved or conflicts with a class method.
|
|
87
89
|
"""
|
|
88
90
|
for key, value in kwargs.items():
|
|
89
91
|
if key.startswith('__') and key.endswith('__'):
|
|
@@ -94,7 +96,7 @@ class StdClass(IStdClass):
|
|
|
94
96
|
|
|
95
97
|
def remove(self, *attributes):
|
|
96
98
|
"""
|
|
97
|
-
|
|
99
|
+
Remove one or more attributes from the object.
|
|
98
100
|
|
|
99
101
|
Parameters
|
|
100
102
|
----------
|
|
@@ -104,7 +106,7 @@ class StdClass(IStdClass):
|
|
|
104
106
|
Raises
|
|
105
107
|
------
|
|
106
108
|
AttributeError
|
|
107
|
-
If any of the attributes
|
|
109
|
+
If any of the specified attributes do not exist.
|
|
108
110
|
"""
|
|
109
111
|
for attr in attributes:
|
|
110
112
|
if not hasattr(self, attr):
|
|
@@ -114,16 +116,16 @@ class StdClass(IStdClass):
|
|
|
114
116
|
@classmethod
|
|
115
117
|
def fromDict(cls, dictionary):
|
|
116
118
|
"""
|
|
117
|
-
|
|
119
|
+
Create a StdClass instance from a dictionary.
|
|
118
120
|
|
|
119
121
|
Parameters
|
|
120
122
|
----------
|
|
121
123
|
dictionary : dict
|
|
122
|
-
Dictionary
|
|
124
|
+
Dictionary containing attribute names and values.
|
|
123
125
|
|
|
124
126
|
Returns
|
|
125
127
|
-------
|
|
126
128
|
StdClass
|
|
127
|
-
A new StdClass instance with
|
|
129
|
+
A new StdClass instance with attributes set from the dictionary.
|
|
128
130
|
"""
|
|
129
131
|
return cls(**dictionary)
|
|
@@ -8,9 +8,6 @@ class DotDict(dict):
|
|
|
8
8
|
"""
|
|
9
9
|
Retrieve the value associated with the given key as an attribute.
|
|
10
10
|
|
|
11
|
-
If the value is a dictionary (but not already a DotDict), it is converted
|
|
12
|
-
to a DotDict and updated in-place. If the key does not exist, returns None.
|
|
13
|
-
|
|
14
11
|
Parameters
|
|
15
12
|
----------
|
|
16
13
|
key : str
|
|
@@ -24,8 +21,8 @@ class DotDict(dict):
|
|
|
24
21
|
|
|
25
22
|
Notes
|
|
26
23
|
-----
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
Allows attribute-style access to dictionary keys. If the value is a plain
|
|
25
|
+
dictionary, it is automatically wrapped as a DotDict for consistency.
|
|
29
26
|
"""
|
|
30
27
|
try:
|
|
31
28
|
value = self[key] # Attempt to retrieve the value by key
|
|
@@ -42,10 +39,6 @@ class DotDict(dict):
|
|
|
42
39
|
"""
|
|
43
40
|
Assign a value to an attribute of the DotDict instance.
|
|
44
41
|
|
|
45
|
-
This method enables attribute-style assignment for dictionary keys. If the
|
|
46
|
-
assigned value is a plain dictionary (not a DotDict), it is automatically
|
|
47
|
-
converted to a DotDict for consistency and recursive attribute access.
|
|
48
|
-
|
|
49
42
|
Parameters
|
|
50
43
|
----------
|
|
51
44
|
key : str
|
|
@@ -57,14 +50,13 @@ class DotDict(dict):
|
|
|
57
50
|
Returns
|
|
58
51
|
-------
|
|
59
52
|
None
|
|
60
|
-
This method does not return a value.
|
|
61
53
|
|
|
62
54
|
Notes
|
|
63
55
|
-----
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
Enables attribute-style assignment for dictionary keys. If the assigned value
|
|
57
|
+
is a plain dictionary (not a DotDict), it is automatically converted to a
|
|
58
|
+
DotDict for consistency and recursive attribute access.
|
|
66
59
|
"""
|
|
67
|
-
|
|
68
60
|
# Convert plain dicts to DotDict for recursive attribute access
|
|
69
61
|
if isinstance(value, dict) and not isinstance(value, DotDict):
|
|
70
62
|
value = DotDict(value)
|
|
@@ -76,9 +68,6 @@ class DotDict(dict):
|
|
|
76
68
|
"""
|
|
77
69
|
Remove an attribute from the DotDict instance.
|
|
78
70
|
|
|
79
|
-
This method deletes the key-value pair corresponding to the given attribute name
|
|
80
|
-
from the underlying dictionary. If the key does not exist, an AttributeError is raised.
|
|
81
|
-
|
|
82
71
|
Parameters
|
|
83
72
|
----------
|
|
84
73
|
key : str
|
|
@@ -87,7 +76,6 @@ class DotDict(dict):
|
|
|
87
76
|
Returns
|
|
88
77
|
-------
|
|
89
78
|
None
|
|
90
|
-
This method does not return a value.
|
|
91
79
|
|
|
92
80
|
Raises
|
|
93
81
|
------
|
|
@@ -96,7 +84,7 @@ class DotDict(dict):
|
|
|
96
84
|
|
|
97
85
|
Notes
|
|
98
86
|
-----
|
|
99
|
-
|
|
87
|
+
Enables attribute-style deletion for dictionary keys, allowing
|
|
100
88
|
seamless removal of items using dot notation.
|
|
101
89
|
"""
|
|
102
90
|
try:
|
|
@@ -110,10 +98,6 @@ class DotDict(dict):
|
|
|
110
98
|
"""
|
|
111
99
|
Retrieve the value associated with the given key, returning a default value if the key is not found.
|
|
112
100
|
|
|
113
|
-
If the retrieved value is a plain dictionary (not a DotDict), it is converted to a DotDict,
|
|
114
|
-
stored back in the dictionary, and then returned. This ensures consistent attribute-style access
|
|
115
|
-
for nested dictionaries.
|
|
116
|
-
|
|
117
101
|
Parameters
|
|
118
102
|
----------
|
|
119
103
|
key : str
|
|
@@ -129,7 +113,7 @@ class DotDict(dict):
|
|
|
129
113
|
|
|
130
114
|
Notes
|
|
131
115
|
-----
|
|
132
|
-
|
|
116
|
+
Overrides the standard dict.get() to provide automatic conversion of nested
|
|
133
117
|
dictionaries to DotDict instances, enabling recursive attribute-style access.
|
|
134
118
|
"""
|
|
135
119
|
# Retrieve the value using the base dict's get method
|
|
@@ -144,27 +128,17 @@ class DotDict(dict):
|
|
|
144
128
|
"""
|
|
145
129
|
Recursively export the contents of the DotDict as a standard Python dictionary.
|
|
146
130
|
|
|
147
|
-
This method traverses the DotDict and converts all nested DotDict instances
|
|
148
|
-
into regular dictionaries by recursively calling their `export` method.
|
|
149
|
-
Non-DotDict values are included as-is. This ensures that the returned object
|
|
150
|
-
is composed entirely of built-in Python types, making it suitable for serialization
|
|
151
|
-
or interoperability with code expecting standard dictionaries.
|
|
152
|
-
|
|
153
|
-
Parameters
|
|
154
|
-
----------
|
|
155
|
-
None
|
|
156
|
-
|
|
157
131
|
Returns
|
|
158
132
|
-------
|
|
159
|
-
|
|
133
|
+
dict
|
|
160
134
|
A dictionary representation of the DotDict, where all nested DotDict instances
|
|
161
135
|
are recursively converted to dictionaries. Non-DotDict values are returned unchanged.
|
|
162
136
|
|
|
163
137
|
Notes
|
|
164
138
|
-----
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
139
|
+
Converts all nested DotDict instances into regular dictionaries by recursively
|
|
140
|
+
calling their `export` method. Useful for serialization or interoperability
|
|
141
|
+
with code expecting standard dictionaries.
|
|
168
142
|
"""
|
|
169
143
|
result = {}
|
|
170
144
|
# Iterate through all key-value pairs in the DotDict
|
|
@@ -181,10 +155,6 @@ class DotDict(dict):
|
|
|
181
155
|
"""
|
|
182
156
|
Create a deep copy of the DotDict instance, recursively copying all nested DotDict and dict objects.
|
|
183
157
|
|
|
184
|
-
This method traverses the DotDict and ensures that all nested DotDict and dict instances are
|
|
185
|
-
copied recursively, so that the returned DotDict is fully independent of the original. Non-dict
|
|
186
|
-
values are copied by reference.
|
|
187
|
-
|
|
188
158
|
Returns
|
|
189
159
|
-------
|
|
190
160
|
DotDict
|
|
@@ -193,8 +163,8 @@ class DotDict(dict):
|
|
|
193
163
|
|
|
194
164
|
Notes
|
|
195
165
|
-----
|
|
196
|
-
|
|
197
|
-
|
|
166
|
+
Ensures that all nested DotDict and dict instances are copied recursively,
|
|
167
|
+
so that the returned DotDict is fully independent of the original.
|
|
198
168
|
"""
|
|
199
169
|
copied = {}
|
|
200
170
|
# Iterate through all key-value pairs in the DotDict
|
|
@@ -215,11 +185,6 @@ class DotDict(dict):
|
|
|
215
185
|
"""
|
|
216
186
|
Return a string representation of the DotDict instance.
|
|
217
187
|
|
|
218
|
-
This method overrides the default `__repr__` implementation to provide a concise
|
|
219
|
-
and informative string that displays the class name (`DotDict`) and the contents
|
|
220
|
-
of the underlying dictionary. This is useful for debugging and logging, as it
|
|
221
|
-
clearly distinguishes DotDict objects from regular dictionaries.
|
|
222
|
-
|
|
223
188
|
Returns
|
|
224
189
|
-------
|
|
225
190
|
str
|
|
@@ -228,8 +193,8 @@ class DotDict(dict):
|
|
|
228
193
|
|
|
229
194
|
Notes
|
|
230
195
|
-----
|
|
231
|
-
|
|
232
|
-
|
|
196
|
+
Uses the base dict's __repr__ for the contents, but keeps the DotDict class name
|
|
197
|
+
for clarity and distinction from regular dictionaries.
|
|
233
198
|
"""
|
|
234
199
|
# Use the base dict's __repr__ for the contents, but keep DotDict class name
|
|
235
|
-
return super().__repr__()
|
|
200
|
+
return super().__repr__()
|
|
@@ -3,132 +3,68 @@ from orionis.test.output.dumper import TestDumper
|
|
|
3
3
|
|
|
4
4
|
class AsyncTestCase(unittest.IsolatedAsyncioTestCase, TestDumper):
|
|
5
5
|
"""
|
|
6
|
-
Base
|
|
6
|
+
Base class for asynchronous unit tests in the Orionis framework.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
The class provides hooks for custom async setup and teardown logic through the
|
|
13
|
-
onAsyncSetup() and onAsyncTeardown() methods, which can be overridden by subclasses
|
|
14
|
-
to implement test-specific asynchronous initialization and cleanup procedures.
|
|
15
|
-
|
|
16
|
-
Each test method runs in its own isolated asyncio event loop, ensuring proper
|
|
17
|
-
isolation and preventing side effects between tests.
|
|
8
|
+
Inherits from `unittest.IsolatedAsyncioTestCase` and `TestDumper`, providing
|
|
9
|
+
a structure for writing asynchronous tests with isolated event loops and
|
|
10
|
+
enhanced output capabilities. Subclasses can override `onAsyncSetup` and
|
|
11
|
+
`onAsyncTeardown` for custom asynchronous setup and teardown logic.
|
|
18
12
|
|
|
19
13
|
Attributes
|
|
20
14
|
----------
|
|
21
15
|
None
|
|
22
|
-
|
|
23
|
-
Methods
|
|
24
|
-
-------
|
|
25
|
-
asyncSetUp()
|
|
26
|
-
Initialize test environment before each async test method execution.
|
|
27
|
-
asyncTearDown()
|
|
28
|
-
Clean up test environment after each async test method execution.
|
|
29
|
-
onAsyncSetup()
|
|
30
|
-
Hook method for subclass-specific async setup logic.
|
|
31
|
-
onAsyncTeardown()
|
|
32
|
-
Hook method for subclass-specific async teardown logic.
|
|
33
16
|
"""
|
|
34
17
|
|
|
35
18
|
async def asyncSetUp(self):
|
|
36
19
|
"""
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
This method is automatically called by the unittest framework before
|
|
40
|
-
each async test method execution. It performs the standard unittest
|
|
41
|
-
async setup and then calls the onAsyncSetup() hook for custom
|
|
42
|
-
asynchronous initialization.
|
|
20
|
+
Asynchronous setup executed before each test method.
|
|
43
21
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
None
|
|
22
|
+
Calls the parent class's asyncSetUp and then invokes the
|
|
23
|
+
`onAsyncSetup` hook for additional subclass-specific setup.
|
|
47
24
|
|
|
48
25
|
Returns
|
|
49
26
|
-------
|
|
50
27
|
None
|
|
51
|
-
|
|
52
|
-
Notes
|
|
53
|
-
-----
|
|
54
|
-
This method should not be overridden directly. Use onAsyncSetup() instead
|
|
55
|
-
for custom async setup logic. The method runs in the isolated event loop
|
|
56
|
-
created for each test.
|
|
57
28
|
"""
|
|
58
29
|
await super().asyncSetUp()
|
|
59
30
|
await self.onAsyncSetup()
|
|
60
31
|
|
|
61
32
|
async def asyncTearDown(self):
|
|
62
33
|
"""
|
|
63
|
-
|
|
34
|
+
Asynchronous teardown executed after each test method.
|
|
64
35
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
for custom cleanup and then performs the standard unittest async teardown.
|
|
68
|
-
|
|
69
|
-
Parameters
|
|
70
|
-
----------
|
|
71
|
-
None
|
|
36
|
+
Invokes the `onAsyncTeardown` hook for subclass-specific cleanup,
|
|
37
|
+
then calls the parent class's asyncTearDown.
|
|
72
38
|
|
|
73
39
|
Returns
|
|
74
40
|
-------
|
|
75
41
|
None
|
|
76
|
-
|
|
77
|
-
Notes
|
|
78
|
-
-----
|
|
79
|
-
This method should not be overridden directly. Use onAsyncTeardown() instead
|
|
80
|
-
for custom async teardown logic. The method runs in the same isolated event
|
|
81
|
-
loop as the test.
|
|
82
42
|
"""
|
|
83
43
|
await self.onAsyncTeardown()
|
|
84
44
|
await super().asyncTearDown()
|
|
85
45
|
|
|
86
46
|
async def onAsyncSetup(self):
|
|
87
47
|
"""
|
|
88
|
-
Hook
|
|
89
|
-
|
|
90
|
-
This method is called during the asyncSetUp() phase and is intended to be
|
|
91
|
-
overridden by subclasses that need to perform custom asynchronous
|
|
92
|
-
initialization before each test method execution.
|
|
48
|
+
Hook for subclass-specific asynchronous setup logic.
|
|
93
49
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
None
|
|
50
|
+
Intended to be overridden by subclasses to perform custom
|
|
51
|
+
asynchronous initialization before each test.
|
|
97
52
|
|
|
98
53
|
Returns
|
|
99
54
|
-------
|
|
100
55
|
None
|
|
101
|
-
|
|
102
|
-
Examples
|
|
103
|
-
--------
|
|
104
|
-
>>> async def onAsyncSetup(self):
|
|
105
|
-
... self.db_connection = await create_async_connection()
|
|
106
|
-
... self.mock_service = AsyncMockService()
|
|
107
|
-
... await self.mock_service.initialize()
|
|
108
56
|
"""
|
|
109
57
|
pass
|
|
110
58
|
|
|
111
59
|
async def onAsyncTeardown(self):
|
|
112
60
|
"""
|
|
113
|
-
Hook
|
|
61
|
+
Hook for subclass-specific asynchronous teardown logic.
|
|
114
62
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
after each test method execution.
|
|
118
|
-
|
|
119
|
-
Parameters
|
|
120
|
-
----------
|
|
121
|
-
None
|
|
63
|
+
Intended to be overridden by subclasses to perform custom
|
|
64
|
+
asynchronous cleanup after each test.
|
|
122
65
|
|
|
123
66
|
Returns
|
|
124
67
|
-------
|
|
125
68
|
None
|
|
126
|
-
|
|
127
|
-
Examples
|
|
128
|
-
--------
|
|
129
|
-
>>> async def onAsyncTeardown(self):
|
|
130
|
-
... await self.db_connection.close()
|
|
131
|
-
... await self.mock_service.cleanup()
|
|
132
|
-
... del self.test_data
|
|
133
69
|
"""
|
|
134
70
|
pass
|