orionis 0.405.0__py3-none-any.whl → 0.407.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.
Files changed (175) hide show
  1. orionis/console/base/command.py +57 -50
  2. orionis/console/base/contracts/command.py +68 -0
  3. orionis/console/dynamic/contracts/progress_bar.py +3 -3
  4. orionis/console/dynamic/progress_bar.py +8 -8
  5. orionis/console/output/console.py +8 -2
  6. orionis/console/output/contracts/console.py +1 -1
  7. orionis/container/container.py +2 -2
  8. orionis/container/context/scope.py +4 -1
  9. orionis/container/contracts/service_provider.py +2 -2
  10. orionis/container/entities/binding.py +31 -44
  11. orionis/container/enums/lifetimes.py +22 -1
  12. orionis/container/facades/facade.py +1 -2
  13. orionis/container/providers/service_provider.py +2 -2
  14. orionis/foundation/application.py +542 -248
  15. orionis/foundation/config/app/entities/app.py +107 -90
  16. orionis/foundation/config/auth/entities/auth.py +4 -33
  17. orionis/foundation/config/cache/entities/cache.py +18 -41
  18. orionis/foundation/config/cache/entities/file.py +8 -35
  19. orionis/foundation/config/cache/entities/stores.py +17 -38
  20. orionis/foundation/config/cors/entities/cors.py +41 -54
  21. orionis/foundation/config/database/entities/connections.py +40 -56
  22. orionis/foundation/config/database/entities/database.py +11 -38
  23. orionis/foundation/config/database/entities/mysql.py +48 -76
  24. orionis/foundation/config/database/entities/oracle.py +30 -57
  25. orionis/foundation/config/database/entities/pgsql.py +45 -61
  26. orionis/foundation/config/database/entities/sqlite.py +26 -53
  27. orionis/foundation/config/filesystems/entitites/aws.py +28 -49
  28. orionis/foundation/config/filesystems/entitites/disks.py +27 -47
  29. orionis/foundation/config/filesystems/entitites/filesystems.py +15 -37
  30. orionis/foundation/config/filesystems/entitites/local.py +9 -35
  31. orionis/foundation/config/filesystems/entitites/public.py +14 -41
  32. orionis/foundation/config/logging/entities/channels.py +56 -86
  33. orionis/foundation/config/logging/entities/chunked.py +9 -9
  34. orionis/foundation/config/logging/entities/daily.py +8 -8
  35. orionis/foundation/config/logging/entities/hourly.py +6 -6
  36. orionis/foundation/config/logging/entities/logging.py +12 -18
  37. orionis/foundation/config/logging/entities/monthly.py +7 -7
  38. orionis/foundation/config/logging/entities/stack.py +5 -5
  39. orionis/foundation/config/logging/entities/weekly.py +6 -6
  40. orionis/foundation/config/mail/entities/file.py +9 -36
  41. orionis/foundation/config/mail/entities/mail.py +22 -40
  42. orionis/foundation/config/mail/entities/mailers.py +29 -44
  43. orionis/foundation/config/mail/entities/smtp.py +47 -48
  44. orionis/foundation/config/queue/entities/brokers.py +19 -41
  45. orionis/foundation/config/queue/entities/database.py +24 -46
  46. orionis/foundation/config/queue/entities/queue.py +28 -40
  47. orionis/foundation/config/roots/paths.py +272 -468
  48. orionis/foundation/config/session/entities/session.py +23 -53
  49. orionis/foundation/config/startup.py +165 -135
  50. orionis/foundation/config/testing/entities/testing.py +137 -122
  51. orionis/foundation/config/testing/enums/__init__.py +6 -2
  52. orionis/foundation/config/testing/enums/drivers.py +16 -0
  53. orionis/foundation/config/testing/enums/verbosity.py +18 -0
  54. orionis/foundation/contracts/application.py +152 -362
  55. orionis/foundation/providers/console_provider.py +24 -2
  56. orionis/foundation/providers/dumper_provider.py +24 -2
  57. orionis/foundation/providers/logger_provider.py +24 -2
  58. orionis/foundation/providers/path_resolver_provider.py +25 -2
  59. orionis/foundation/providers/progress_bar_provider.py +24 -2
  60. orionis/foundation/providers/testing_provider.py +39 -0
  61. orionis/foundation/providers/workers_provider.py +24 -2
  62. orionis/metadata/framework.py +1 -1
  63. orionis/services/asynchrony/contracts/coroutines.py +13 -5
  64. orionis/services/asynchrony/coroutines.py +33 -29
  65. orionis/services/asynchrony/exceptions/exception.py +9 -1
  66. orionis/services/environment/core/dot_env.py +46 -34
  67. orionis/services/environment/enums/__init__.py +0 -0
  68. orionis/services/environment/enums/cast_type.py +42 -0
  69. orionis/services/environment/helpers/functions.py +1 -2
  70. orionis/services/environment/key/__init__.py +0 -0
  71. orionis/services/environment/key/key_generator.py +37 -0
  72. orionis/services/environment/serializer/__init__.py +0 -0
  73. orionis/services/environment/serializer/values.py +21 -0
  74. orionis/services/environment/validators/__init__.py +0 -0
  75. orionis/services/environment/validators/key_name.py +46 -0
  76. orionis/services/environment/validators/types.py +45 -0
  77. orionis/services/system/contracts/imports.py +38 -18
  78. orionis/services/system/contracts/workers.py +29 -12
  79. orionis/services/system/imports.py +65 -25
  80. orionis/services/system/runtime/imports.py +18 -9
  81. orionis/services/system/workers.py +49 -16
  82. orionis/support/entities/__init__.py +0 -0
  83. orionis/support/entities/base.py +104 -0
  84. orionis/support/facades/testing.py +15 -0
  85. orionis/support/facades/workers.py +1 -1
  86. orionis/test/cases/asynchronous.py +0 -11
  87. orionis/test/cases/synchronous.py +0 -9
  88. orionis/test/contracts/dumper.py +11 -4
  89. orionis/test/contracts/kernel.py +5 -110
  90. orionis/test/contracts/logs.py +27 -65
  91. orionis/test/contracts/printer.py +16 -128
  92. orionis/test/contracts/test_result.py +100 -0
  93. orionis/test/contracts/unit_test.py +87 -150
  94. orionis/test/core/unit_test.py +608 -554
  95. orionis/test/entities/result.py +22 -2
  96. orionis/test/enums/__init__.py +0 -2
  97. orionis/test/enums/status.py +14 -9
  98. orionis/test/exceptions/config.py +9 -1
  99. orionis/test/exceptions/failure.py +34 -11
  100. orionis/test/exceptions/persistence.py +10 -2
  101. orionis/test/exceptions/runtime.py +9 -1
  102. orionis/test/exceptions/value.py +13 -1
  103. orionis/test/kernel.py +87 -289
  104. orionis/test/output/dumper.py +83 -18
  105. orionis/test/output/printer.py +399 -156
  106. orionis/test/records/logs.py +203 -82
  107. orionis/test/validators/__init__.py +33 -0
  108. orionis/test/validators/base_path.py +45 -0
  109. orionis/test/validators/execution_mode.py +45 -0
  110. orionis/test/validators/fail_fast.py +37 -0
  111. orionis/test/validators/folder_path.py +34 -0
  112. orionis/test/validators/module_name.py +31 -0
  113. orionis/test/validators/name_pattern.py +40 -0
  114. orionis/test/validators/pattern.py +36 -0
  115. orionis/test/validators/persistent.py +42 -0
  116. orionis/test/validators/persistent_driver.py +43 -0
  117. orionis/test/validators/print_result.py +37 -0
  118. orionis/test/validators/tags.py +37 -0
  119. orionis/test/validators/throw_exception.py +39 -0
  120. orionis/test/validators/verbosity.py +37 -0
  121. orionis/test/validators/web_report.py +35 -0
  122. orionis/test/validators/workers.py +31 -0
  123. orionis/test/view/render.py +48 -54
  124. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/METADATA +1 -1
  125. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/RECORD +170 -112
  126. tests/container/__init__.py +0 -0
  127. tests/container/context/__init__.py +0 -0
  128. tests/container/context/test_manager.py +27 -0
  129. tests/container/context/test_scope.py +23 -0
  130. tests/container/entities/__init__.py +0 -0
  131. tests/container/entities/test_binding.py +133 -0
  132. tests/container/enums/__init__.py +0 -0
  133. tests/container/enums/test_lifetimes.py +63 -0
  134. tests/container/facades/__init__.py +0 -0
  135. tests/container/facades/test_facade.py +61 -0
  136. tests/container/mocks/__init__.py +0 -0
  137. tests/container/mocks/mock_complex_classes.py +482 -0
  138. tests/container/mocks/mock_simple_classes.py +32 -0
  139. tests/container/providers/__init__.py +0 -0
  140. tests/container/providers/test_providers.py +48 -0
  141. tests/container/resolver/__init__.py +0 -0
  142. tests/container/resolver/test_resolver.py +55 -0
  143. tests/container/test_container.py +254 -0
  144. tests/container/test_singleton.py +98 -0
  145. tests/container/test_thread_safety.py +217 -0
  146. tests/container/validators/__init__.py +0 -0
  147. tests/container/validators/test_implements.py +140 -0
  148. tests/container/validators/test_is_abstract_class.py +99 -0
  149. tests/container/validators/test_is_callable.py +73 -0
  150. tests/container/validators/test_is_concrete_class.py +97 -0
  151. tests/container/validators/test_is_instance.py +105 -0
  152. tests/container/validators/test_is_not_subclass.py +117 -0
  153. tests/container/validators/test_is_subclass.py +115 -0
  154. tests/container/validators/test_is_valid_alias.py +113 -0
  155. tests/container/validators/test_lifetime.py +75 -0
  156. tests/example/test_example.py +2 -2
  157. tests/foundation/config/testing/test_foundation_config_testing.py +1 -1
  158. tests/metadata/test_metadata_framework.py +89 -24
  159. tests/metadata/test_metadata_package.py +55 -10
  160. tests/services/asynchrony/test_services_asynchrony_coroutine.py +52 -7
  161. tests/services/system/test_services_system_imports.py +119 -16
  162. tests/services/system/test_services_system_workers.py +71 -30
  163. tests/testing/test_testing_result.py +117 -117
  164. tests/testing/test_testing_unit.py +209 -209
  165. orionis/foundation/config/base.py +0 -112
  166. orionis/test/arguments/parser.py +0 -187
  167. orionis/test/contracts/parser.py +0 -43
  168. orionis/test/entities/arguments.py +0 -38
  169. orionis/test/enums/execution_mode.py +0 -16
  170. /orionis/{test/arguments → console/base/contracts}/__init__.py +0 -0
  171. /orionis/foundation/config/testing/enums/{test_mode.py → mode.py} +0 -0
  172. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/WHEEL +0 -0
  173. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/licenses/LICENCE +0 -0
  174. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/top_level.txt +0 -0
  175. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/zip-safe +0 -0
@@ -1,5 +1,6 @@
1
1
  from abc import ABC, abstractmethod
2
2
  from typing import Any, Dict
3
+ from orionis.test.entities.result import TestResult
3
4
 
4
5
  class ITestPrinter(ABC):
5
6
 
@@ -8,106 +9,37 @@ class ITestPrinter(ABC):
8
9
  self,
9
10
  value: Any
10
11
  ) -> 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
- """
12
+ """Prints a value to the console using the rich console."""
23
13
  pass
24
14
 
25
15
  @abstractmethod
26
16
  def startMessage(
27
17
  self,
28
18
  *,
29
- print_result: bool,
30
19
  length_tests: int,
31
20
  execution_mode: str,
32
21
  max_workers: int
33
22
  ):
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
- """
23
+ """Displays a formatted start message for the test execution session."""
52
24
  pass
53
25
 
54
26
  @abstractmethod
55
27
  def finishMessage(
56
28
  self,
57
29
  *,
58
- print_result: bool,
59
30
  summary: Dict[str, Any]
60
31
  ) -> 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
- """
32
+ """Display a summary message for the test suite execution."""
77
33
  pass
78
34
 
79
35
  @abstractmethod
80
36
  def executePanel(
81
37
  self,
82
38
  *,
83
- print_result: bool,
84
39
  flatten_test_suite: list,
85
40
  callable: callable
86
41
  ):
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
- """
42
+ """Executes a test suite panel with optional live console output."""
111
43
  pass
112
44
 
113
45
  @abstractmethod
@@ -115,14 +47,7 @@ class ITestPrinter(ABC):
115
47
  self,
116
48
  path: str
117
49
  ):
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
- """
50
+ """Prints an invitation to view the test results, with an underlined path."""
126
51
  pass
127
52
 
128
53
  @abstractmethod
@@ -130,59 +55,22 @@ class ITestPrinter(ABC):
130
55
  self,
131
56
  summary: Dict[str, Any]
132
57
  ) -> 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
- """
58
+ """Prints a summary table of test results using the Rich library."""
159
59
  pass
160
60
 
161
61
  @abstractmethod
162
62
  def displayResults(
163
63
  self,
164
64
  *,
165
- print_result: bool,
166
65
  summary: Dict[str, Any]
167
66
  ) -> 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.
67
+ """Display the results of the test execution, including a summary table and details."""
68
+ pass
177
69
 
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
70
+ @abstractmethod
71
+ def unittestResult(
72
+ self,
73
+ test_result: TestResult
74
+ ) -> None:
75
+ """Display the result of a single unit test in a formatted manner."""
76
+ pass
@@ -0,0 +1,100 @@
1
+ import unittest
2
+ from abc import ABC, abstractmethod
3
+ from typing import List, Dict, Optional, Tuple
4
+ from orionis.test.entities.result import TestResult
5
+
6
+ class IOrionisTestResult(ABC):
7
+ """
8
+ Interface for OrionisTestResult, a custom test result collector that extends
9
+ unittest's TextTestResult to include rich execution metadata such as
10
+ execution time, error tracebacks, and reflection-based information.
11
+
12
+ Classes implementing this interface are responsible for capturing detailed
13
+ information about each test case execution, including success, failure,
14
+ error, and skip states.
15
+ """
16
+
17
+ @property
18
+ @abstractmethod
19
+ def test_results(self) -> List[TestResult]:
20
+ """
21
+ A list containing the detailed results of each executed test case.
22
+
23
+ Each entry is an instance of `TestResult`, storing metadata such as
24
+ status, execution time, method name, module, file, and optional error info.
25
+ """
26
+ pass
27
+
28
+ @property
29
+ @abstractmethod
30
+ def _test_timings(self) -> Dict[unittest.case.TestCase, float]:
31
+ """
32
+ Internal mapping from each test case to its execution duration in seconds.
33
+ Used to compute elapsed time between `startTest()` and `stopTest()`.
34
+ """
35
+ pass
36
+
37
+ @property
38
+ @abstractmethod
39
+ def _current_test_start(self) -> Optional[float]:
40
+ """
41
+ Timestamp (in seconds) marking the beginning of the currently running test.
42
+ Used internally to calculate duration.
43
+ """
44
+ pass
45
+
46
+ @abstractmethod
47
+ def startTest(self, test: unittest.case.TestCase) -> None:
48
+ """
49
+ Called before the test is run.
50
+
51
+ Records the current start time for the test case in `_current_test_start`.
52
+ """
53
+ pass
54
+
55
+ @abstractmethod
56
+ def stopTest(self, test: unittest.case.TestCase) -> None:
57
+ """
58
+ Called after the test has run.
59
+
60
+ Calculates and stores the execution time for the test in `_test_timings`.
61
+ """
62
+ pass
63
+
64
+ @abstractmethod
65
+ def addSuccess(self, test: unittest.case.TestCase) -> None:
66
+ """
67
+ Called when a test case completes successfully.
68
+
69
+ Appends a `TestResult` instance with status `PASSED` to `test_results`.
70
+ """
71
+ pass
72
+
73
+ @abstractmethod
74
+ def addFailure(self, test: unittest.case.TestCase, err: Tuple[BaseException, BaseException, object]) -> None:
75
+ """
76
+ Called when a test case fails due to an assertion failure.
77
+
78
+ Captures and appends a `TestResult` instance with status `FAILED`, along
79
+ with traceback and error message.
80
+ """
81
+ pass
82
+
83
+ @abstractmethod
84
+ def addError(self, test: unittest.case.TestCase, err: Tuple[BaseException, BaseException, object]) -> None:
85
+ """
86
+ Called when a test case encounters an unexpected error or exception.
87
+
88
+ Captures and appends a `TestResult` instance with status `ERRORED`, along
89
+ with traceback and error message.
90
+ """
91
+ pass
92
+
93
+ @abstractmethod
94
+ def addSkip(self, test: unittest.case.TestCase, reason: str) -> None:
95
+ """
96
+ Called when a test case is skipped.
97
+
98
+ Appends a `TestResult` instance with status `SKIPPED` and reason to `test_results`.
99
+ """
100
+ pass
@@ -1,71 +1,54 @@
1
1
  from abc import ABC, abstractmethod
2
+ from pathlib import Path
2
3
  from typing import Any, Dict, List, Optional
3
- from orionis.foundation.contracts.application import IApplication
4
- from orionis.services.system.workers import Workers
5
- from orionis.test.enums.execution_mode import ExecutionMode
4
+ from orionis.foundation.config.testing.enums import ExecutionMode
5
+ from orionis.foundation.config.testing.enums.drivers import PersistentDrivers
6
+ from orionis.foundation.config.testing.enums.verbosity import VerbosityMode
6
7
 
7
8
  class IUnitTest(ABC):
8
9
 
9
10
  @abstractmethod
10
11
  def configure(
11
- self,
12
- *,
13
- verbosity: int = 2,
14
- execution_mode: str | ExecutionMode = ExecutionMode.SEQUENTIAL,
15
- max_workers: int = Workers().calculate(),
16
- fail_fast: bool = False,
17
- print_result: bool = True,
18
- throw_exception: bool = False,
19
- persistent: bool = False,
20
- persistent_driver: str = 'sqlite',
21
- web_report: bool = False
22
- ):
23
- """
24
- Configures the UnitTest instance with the specified parameters.
25
-
26
- Parameters
27
- ----------
28
- verbosity : int, optional
29
- The verbosity level for test output. If None, the current setting is retained.
30
- execution_mode : str or ExecutionMode, optional
31
- The mode in which the tests will be executed ('SEQUENTIAL' or 'PARALLEL'). If None, the current setting is retained.
32
- max_workers : int, optional
33
- The maximum number of workers to use for parallel execution. If None, the current setting is retained.
34
- fail_fast : bool, optional
35
- Whether to stop execution upon the first failure. If None, the current setting is retained.
36
- print_result : bool, optional
37
- Whether to print the test results after execution. If None, the current setting is retained.
38
- throw_exception : bool, optional
39
- Whether to throw an exception if any test fails. Defaults to False.
40
- persistent : bool, optional
41
- Whether to persist the test results in a database. Defaults to False.
42
- persistent_driver : str, optional
43
- The driver to use for persistent storage. Defaults to 'sqlite'.
44
-
45
- Returns
46
- -------
47
- UnitTest
48
- The configured UnitTest instance.
49
- """
50
- pass
51
-
52
- @abstractmethod
53
- def setApplication(
54
12
  self,
55
- app: 'IApplication'
56
- ):
57
- """
58
- Set the application instance for the UnitTest.
59
- This method allows the UnitTest to access the application instance, which is necessary for resolving dependencies and executing tests.
13
+ *,
14
+ verbosity: int | VerbosityMode,
15
+ execution_mode: str | ExecutionMode,
16
+ max_workers: int,
17
+ fail_fast: bool,
18
+ print_result: bool,
19
+ throw_exception: bool,
20
+ persistent: bool,
21
+ persistent_driver: str | PersistentDrivers,
22
+ web_report: bool
23
+ ) -> 'IUnitTest':
24
+ """
25
+ Configure the unit test runner with the specified options.
60
26
 
61
27
  Parameters
62
28
  ----------
63
- app : IApplication
64
- The application instance to be set for the UnitTest.
29
+ verbosity : int or VerbosityMode
30
+ Level of verbosity for test output.
31
+ execution_mode : str or ExecutionMode
32
+ Mode in which tests are executed (e.g., sequential, parallel).
33
+ max_workers : int
34
+ Maximum number of worker threads or processes.
35
+ fail_fast : bool
36
+ If True, stop execution on first failure.
37
+ print_result : bool
38
+ If True, print test results to the console.
39
+ throw_exception : bool
40
+ If True, raise exceptions on test failures.
41
+ persistent : bool
42
+ If True, enable persistent storage for test results.
43
+ persistent_driver : str | PersistentDrivers
44
+ Name of the persistent storage driver.
45
+ web_report : bool
46
+ If True, generate a web-based test report.
65
47
 
66
48
  Returns
67
49
  -------
68
- UnitTest
50
+ IUnitTest
51
+ The configured unit test runner instance.
69
52
  """
70
53
  pass
71
54
 
@@ -73,39 +56,32 @@ class IUnitTest(ABC):
73
56
  def discoverTestsInFolder(
74
57
  self,
75
58
  *,
76
- base_path: str = "tests",
59
+ base_path: str | Path,
77
60
  folder_path: str,
78
- pattern: str = "test_*.py",
61
+ pattern: str,
79
62
  test_name_pattern: Optional[str] = None,
80
63
  tags: Optional[List[str]] = None
81
- ):
64
+ ) -> 'IUnitTest':
82
65
  """
66
+ Discover test cases in a specified folder.
67
+
83
68
  Parameters
84
69
  ----------
70
+ base_path : str or Path
71
+ Base directory for test discovery.
85
72
  folder_path : str
86
- The relative path to the folder containing the tests.
87
- base_path : str, optional
88
- The base directory where the test folder is located. Defaults to "tests".
89
- pattern : str, optional
90
- The filename pattern to match test files. Defaults to "test_*.py".
91
- test_name_pattern : str or None, optional
92
- A pattern to filter test names. Defaults to None.
93
- tags : list of str or None, optional
94
- A list of tags to filter tests. Defaults to None.
73
+ Relative or absolute path to the folder containing tests.
74
+ pattern : str
75
+ File pattern to match test files (e.g., 'test_*.py').
76
+ test_name_pattern : str, optional
77
+ Pattern to match test function or class names.
78
+ tags : list of str, optional
79
+ List of tags to filter discovered tests.
95
80
 
96
81
  Returns
97
82
  -------
98
- UnitTest
99
- The current instance of the UnitTest class with the discovered tests added.
100
-
101
- Raises
102
- ------
103
- OrionisTestValueError
104
- If the test folder does not exist, no tests are found, or an error occurs during test discovery.
105
-
106
- Notes
107
- -----
108
- This method updates the internal test suite with the discovered tests and tracks the number of tests found.
83
+ IUnitTest
84
+ The unit test runner instance with discovered tests.
109
85
  """
110
86
  pass
111
87
 
@@ -115,152 +91,113 @@ class IUnitTest(ABC):
115
91
  *,
116
92
  module_name: str,
117
93
  test_name_pattern: Optional[str] = None
118
- ):
94
+ ) -> 'IUnitTest':
119
95
  """
120
- Discovers and loads tests from a specified module, optionally filtering by a test name pattern, and adds them to the test suite.
96
+ Discover test cases in a specified module.
121
97
 
122
98
  Parameters
123
99
  ----------
124
100
  module_name : str
125
- Name of the module from which to discover tests.
101
+ Name of the module to search for tests.
126
102
  test_name_pattern : str, optional
127
- Pattern to filter test names. Only tests matching this pattern will be included. Defaults to None.
103
+ Pattern to match test function or class names.
128
104
 
129
105
  Returns
130
106
  -------
131
- UnitTest
132
- The current instance of the UnitTest class, allowing method chaining.
133
-
134
- Exceptions
135
- ----------
136
- OrionisTestValueError
137
- If the specified module cannot be imported.
107
+ IUnitTest
108
+ The unit test runner instance with discovered tests.
138
109
  """
139
110
  pass
140
111
 
141
112
  @abstractmethod
142
- def run(
143
- self
144
- ) -> Dict[str, Any]:
113
+ def run(self) -> Dict[str, Any]:
145
114
  """
146
- Executes the test suite and processes the results.
147
-
148
- Parameters
149
- ----------
150
- print_result : bool, optional
151
- If provided, overrides the instance's `print_result` attribute to determine whether to print results.
152
- throw_exception : bool, optional
153
- If True, raises an exception if any test failures or errors are detected.
115
+ Execute all discovered tests.
154
116
 
155
117
  Returns
156
118
  -------
157
119
  dict
158
- A summary of the test execution, including details such as execution time, results, and timestamp.
159
-
160
- Raises
161
- ------
162
- OrionisTestFailureException
163
- If `throw_exception` is True and there are test failures or errors.
120
+ Dictionary containing the results of the test execution.
164
121
  """
165
122
  pass
166
123
 
167
124
  @abstractmethod
168
- def getTestNames(
169
- self
170
- ) -> List[str]:
125
+ def getTestNames(self) -> List[str]:
171
126
  """
172
- Get a list of test names (unique identifiers) from the test suite.
127
+ Get the list of discovered test names.
173
128
 
174
129
  Returns
175
130
  -------
176
- List[str]
177
- List of test names (unique identifiers) from the test suite.
131
+ list of str
132
+ Names of all discovered tests.
178
133
  """
179
134
  pass
180
135
 
181
136
  @abstractmethod
182
- def getTestCount(
183
- self
184
- ) -> int:
137
+ def getTestCount(self) -> int:
185
138
  """
186
- Returns the total number of test cases in the test suite.
139
+ Get the total number of discovered tests.
187
140
 
188
141
  Returns
189
142
  -------
190
143
  int
191
- The total number of individual test cases in the suite.
144
+ Number of discovered tests.
192
145
  """
193
146
  pass
194
147
 
195
148
  @abstractmethod
196
- def clearTests(
197
- self
198
- ) -> None:
149
+ def clearTests(self) -> None:
199
150
  """
200
- Clear all tests from the current test suite.
201
-
202
- Resets the internal test suite to an empty `unittest.TestSuite`, removing any previously added tests.
151
+ Remove all discovered tests from the runner.
203
152
  """
204
153
  pass
205
154
 
206
155
  @abstractmethod
207
- def getResult(
208
- self
209
- ) -> dict:
156
+ def getResult(self) -> dict:
210
157
  """
211
- Returns the results of the executed test suite.
158
+ Retrieve the results of the last test run.
212
159
 
213
160
  Returns
214
161
  -------
215
- UnitTest
216
- The result of the executed test suite.
162
+ dict
163
+ Dictionary containing the results of the last test execution.
217
164
  """
218
165
  pass
219
166
 
220
167
  @abstractmethod
221
- def getOutputBuffer(
222
- self
223
- ) -> int:
168
+ def getOutputBuffer(self) -> int:
224
169
  """
225
- Returns the output buffer used for capturing test results.
226
- This method returns the internal output buffer that collects the results of the test execution.
170
+ Get the size or identifier of the output buffer.
171
+
227
172
  Returns
228
173
  -------
229
174
  int
230
- The output buffer containing the results of the test execution.
175
+ Output buffer size or identifier.
231
176
  """
232
177
  pass
233
178
 
234
179
  @abstractmethod
235
- def printOutputBuffer(
236
- self
237
- ) -> None:
180
+ def printOutputBuffer(self) -> None:
238
181
  """
239
- Prints the contents of the output buffer to the console.
240
- This method retrieves the output buffer and prints its contents using the rich console.
182
+ Print the contents of the output buffer to the console.
241
183
  """
242
184
  pass
243
185
 
244
186
  @abstractmethod
245
- def getErrorBuffer(
246
- self
247
- ) -> int:
187
+ def getErrorBuffer(self) -> int:
248
188
  """
249
- Returns the error buffer used for capturing test errors.
250
- This method returns the internal error buffer that collects any errors encountered during test execution.
189
+ Get the size or identifier of the error buffer.
190
+
251
191
  Returns
252
192
  -------
253
193
  int
254
- The error buffer containing the errors encountered during the test execution.
194
+ Error buffer size or identifier.
255
195
  """
256
196
  pass
257
197
 
258
198
  @abstractmethod
259
- def printErrorBuffer(
260
- self
261
- ) -> None:
199
+ def printErrorBuffer(self) -> None:
262
200
  """
263
- Prints the contents of the error buffer to the console.
264
- This method retrieves the error buffer and prints its contents using the rich console.
201
+ Print the contents of the error buffer to the console.
265
202
  """
266
203
  pass