orionis 0.286.0__py3-none-any.whl → 0.287.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 (57) hide show
  1. orionis/metadata/framework.py +1 -1
  2. orionis/services/environment/contracts/env.py +45 -50
  3. orionis/services/environment/dot_env.py +205 -181
  4. orionis/services/environment/env.py +68 -85
  5. orionis/services/environment/exceptions/environment_value_error.py +18 -0
  6. orionis/services/environment/exceptions/environment_value_exception.py +23 -0
  7. orionis/services/environment/type_hint.py +559 -0
  8. orionis/test/logs/history.py +3 -5
  9. {orionis-0.286.0.dist-info → orionis-0.287.0.dist-info}/METADATA +1 -1
  10. {orionis-0.286.0.dist-info → orionis-0.287.0.dist-info}/RECORD +56 -54
  11. tests/example/test_example.py +5 -2
  12. tests/foundation/config/app/test_app.py +13 -3
  13. tests/foundation/config/auth/test_auth.py +9 -4
  14. tests/foundation/config/cache/test_cache.py +60 -15
  15. tests/foundation/config/cache/test_cache_file.py +62 -14
  16. tests/foundation/config/cache/test_cache_stores.py +74 -14
  17. tests/foundation/config/cors/test_cors.py +102 -33
  18. tests/foundation/config/database/test_database.py +38 -14
  19. tests/foundation/config/database/test_database_connections.py +79 -5
  20. tests/foundation/config/database/test_database_mysql.py +138 -15
  21. tests/foundation/config/database/test_database_oracle.py +110 -26
  22. tests/foundation/config/database/test_database_pgsql.py +96 -26
  23. tests/foundation/config/database/test_database_sqlite.py +56 -2
  24. tests/foundation/config/exceptions/test_exceptions_integrity.py +44 -10
  25. tests/foundation/config/filesystems/test_filesystems.py +64 -14
  26. tests/foundation/config/filesystems/test_filesystems_aws.py +45 -7
  27. tests/foundation/config/filesystems/test_filesystems_disks.py +78 -8
  28. tests/foundation/config/filesystems/test_filesystems_local.py +66 -18
  29. tests/foundation/config/filesystems/test_filesystems_public.py +37 -0
  30. tests/foundation/config/logging/test_logging.py +75 -11
  31. tests/foundation/config/logging/test_logging_channels.py +79 -2
  32. tests/foundation/config/logging/test_logging_chunked.py +85 -12
  33. tests/foundation/config/logging/test_logging_daily.py +79 -12
  34. tests/foundation/config/logging/test_logging_hourly.py +68 -2
  35. tests/foundation/config/logging/test_logging_monthly.py +48 -2
  36. tests/foundation/config/logging/test_logging_stack.py +49 -14
  37. tests/foundation/config/logging/test_logging_weekly.py +92 -2
  38. tests/foundation/config/mail/test_mail.py +87 -15
  39. tests/foundation/config/mail/test_mail_file.py +40 -4
  40. tests/foundation/config/mail/test_mail_mailers.py +56 -8
  41. tests/foundation/config/mail/test_mail_smtp.py +58 -14
  42. tests/foundation/config/queue/test_queue.py +62 -9
  43. tests/foundation/config/queue/test_queue_brokers.py +27 -10
  44. tests/foundation/config/queue/test_queue_database.py +53 -15
  45. tests/foundation/config/root/test_root_paths.py +69 -2
  46. tests/foundation/config/session/test_session.py +30 -1
  47. tests/foundation/config/startup/test_config_startup.py +77 -7
  48. tests/foundation/config/testing/test_testing.py +68 -0
  49. tests/patterns/singleton/test_singleton.py +10 -1
  50. tests/services/environment/test_env.py +3 -4
  51. tests/testing/test_testing_result.py +56 -19
  52. tests/testing/test_testing_unit.py +93 -24
  53. orionis/services/environment/exceptions/value_exception.py +0 -27
  54. {orionis-0.286.0.dist-info → orionis-0.287.0.dist-info}/WHEEL +0 -0
  55. {orionis-0.286.0.dist-info → orionis-0.287.0.dist-info}/licenses/LICENCE +0 -0
  56. {orionis-0.286.0.dist-info → orionis-0.287.0.dist-info}/top_level.txt +0 -0
  57. {orionis-0.286.0.dist-info → orionis-0.287.0.dist-info}/zip-safe +0 -0
@@ -5,25 +5,60 @@ from orionis.unittesting import TestCase, UnittestMock
5
5
 
6
6
  class TestConfiguration(TestCase):
7
7
  """
8
- Test suite for the Configuration dataclass which encapsulates all major
9
- configuration sections for the application.
8
+ Test suite for the Configuration dataclass.
10
9
 
11
- This test class verifies the proper initialization, type validation,
12
- and dictionary conversion of the Configuration class.
10
+ This class contains unit tests to verify the correct behavior of the
11
+ Configuration dataclass, including initialization, type validation,
12
+ dictionary conversion, metadata accessibility, mutability, and equality.
13
+
14
+ Attributes
15
+ ----------
16
+ None
17
+
18
+ Methods
19
+ -------
20
+ testConfigurationIsDataclass()
21
+ Test that Configuration is properly defined as a dataclass.
22
+ testDefaultInitialization()
23
+ Test that Configuration can be initialized with default values.
24
+ testAllSectionsHaveDefaultFactories()
25
+ Test that all configuration sections have default factories.
26
+ testTypeValidationInPostInit()
27
+ Test that __post_init__ validates types correctly.
28
+ testToDictReturnsCompleteDictionary()
29
+ Test that toDict() returns a complete dictionary representation.
30
+ testToDictReturnsNestedStructures()
31
+ Test that toDict() properly converts nested dataclasses.
32
+ testMetadataIsAccessible()
33
+ Test that field metadata is properly defined and accessible.
34
+ testConfigurationIsMutable()
35
+ Test that Configuration is mutable (not frozen).
36
+ testConfigurationEquality()
37
+ Test that Configuration instances with same values are equal.
13
38
  """
14
39
 
15
40
  def testConfigurationIsDataclass(self):
16
41
  """
17
42
  Test that Configuration is properly defined as a dataclass.
18
- Verifies that the @dataclass decorator was applied correctly.
43
+
44
+ Ensures that the @dataclass decorator was applied correctly.
45
+
46
+ Returns
47
+ -------
48
+ None
19
49
  """
20
50
  self.assertTrue(is_dataclass(Configuration))
21
51
 
22
52
  def testDefaultInitialization(self):
23
53
  """
24
54
  Test that Configuration can be initialized with default values.
25
- Verifies that all default factories work correctly and the
26
- instance is properly constructed.
55
+
56
+ Verifies that all default factories work correctly and the instance
57
+ is properly constructed.
58
+
59
+ Returns
60
+ -------
61
+ None
27
62
  """
28
63
  config = Configuration()
29
64
  self.assertIsInstance(config, Configuration)
@@ -31,8 +66,13 @@ class TestConfiguration(TestCase):
31
66
  def testAllSectionsHaveDefaultFactories(self):
32
67
  """
33
68
  Test that all configuration sections have default factories.
69
+
34
70
  Verifies that each field in the Configuration class has a
35
71
  default_factory specified.
72
+
73
+ Returns
74
+ -------
75
+ None
36
76
  """
37
77
  config = Configuration()
38
78
  for field in config.__dataclass_fields__.values():
@@ -42,8 +82,13 @@ class TestConfiguration(TestCase):
42
82
  def testTypeValidationInPostInit(self):
43
83
  """
44
84
  Test that __post_init__ validates types correctly.
85
+
45
86
  Verifies that the type checking for each configuration section
46
87
  works as expected.
88
+
89
+ Returns
90
+ -------
91
+ None
47
92
  """
48
93
  # Test with all correct types (should not raise)
49
94
  try:
@@ -76,8 +121,13 @@ class TestConfiguration(TestCase):
76
121
  def testToDictReturnsCompleteDictionary(self):
77
122
  """
78
123
  Test that toDict() returns a complete dictionary representation.
124
+
79
125
  Verifies that the returned dictionary contains all configuration
80
126
  sections with their current values.
127
+
128
+ Returns
129
+ -------
130
+ None
81
131
  """
82
132
  config = Configuration()
83
133
  config_dict = config.toDict()
@@ -89,8 +139,13 @@ class TestConfiguration(TestCase):
89
139
  def testToDictReturnsNestedStructures(self):
90
140
  """
91
141
  Test that toDict() properly converts nested dataclasses.
142
+
92
143
  Verifies that the dictionary conversion works recursively for
93
144
  all nested configuration sections.
145
+
146
+ Returns
147
+ -------
148
+ None
94
149
  """
95
150
  config = Configuration()
96
151
  config_dict = config.toDict()
@@ -101,8 +156,13 @@ class TestConfiguration(TestCase):
101
156
  def testMetadataIsAccessible(self):
102
157
  """
103
158
  Test that field metadata is properly defined and accessible.
159
+
104
160
  Verifies that each configuration section field has the expected
105
161
  metadata structure with description.
162
+
163
+ Returns
164
+ -------
165
+ None
106
166
  """
107
167
  config = Configuration()
108
168
  for field in config.__dataclass_fields__.values():
@@ -113,8 +173,13 @@ class TestConfiguration(TestCase):
113
173
  def testConfigurationIsMutable(self):
114
174
  """
115
175
  Test that Configuration is mutable (not frozen).
176
+
116
177
  Verifies that attributes can be modified after creation since
117
178
  the dataclass isn't marked as frozen.
179
+
180
+ Returns
181
+ -------
182
+ None
118
183
  """
119
184
  config = Configuration()
120
185
  new_paths = config.paths.__class__()
@@ -127,7 +192,12 @@ class TestConfiguration(TestCase):
127
192
  def testConfigurationEquality(self):
128
193
  """
129
194
  Test that Configuration instances with same values are equal.
195
+
130
196
  Verifies that dataclass equality comparison works as expected.
197
+
198
+ Returns
199
+ -------
200
+ None
131
201
  """
132
202
  config1 = Configuration()
133
203
  config2 = Configuration()
@@ -4,10 +4,21 @@ from orionis.test.enums.test_mode import ExecutionMode
4
4
  from orionis.unittesting import TestCase
5
5
 
6
6
  class TestTestingConfig(TestCase):
7
+ """
8
+ Test suite for the Testing configuration entity.
9
+
10
+ This class contains asynchronous test cases to validate the default values,
11
+ custom values, and integrity constraints of the Testing configuration.
12
+ """
7
13
 
8
14
  async def testDefaultValues(self):
9
15
  """
10
16
  Test the default values of the Testing configuration.
17
+
18
+ Notes
19
+ -----
20
+ Ensures that all default attributes of the Testing configuration are set
21
+ as expected.
11
22
  """
12
23
  t = Testing()
13
24
  self.assertEqual(t.verbosity, 2)
@@ -25,6 +36,11 @@ class TestTestingConfig(TestCase):
25
36
  async def testValidCustomValues(self):
26
37
  """
27
38
  Test custom valid values for all fields.
39
+
40
+ Notes
41
+ -----
42
+ Verifies that the Testing configuration accepts and correctly sets
43
+ custom valid values for all its fields.
28
44
  """
29
45
  t = Testing(
30
46
  verbosity=1,
@@ -54,6 +70,10 @@ class TestTestingConfig(TestCase):
54
70
  async def testFolderPathStringAndList(self):
55
71
  """
56
72
  Test folder_path accepts both string and list of strings.
73
+
74
+ Notes
75
+ -----
76
+ Checks that the folder_path attribute can be set as a string or a list of strings.
57
77
  """
58
78
  t1 = Testing(folder_path="integration")
59
79
  self.assertEqual(t1.folder_path, "integration")
@@ -63,6 +83,10 @@ class TestTestingConfig(TestCase):
63
83
  async def testTagsNoneOrList(self):
64
84
  """
65
85
  Test tags accepts None or list of strings.
86
+
87
+ Notes
88
+ -----
89
+ Ensures that the tags attribute can be set to None or a list of strings.
66
90
  """
67
91
  t1 = Testing(tags=None)
68
92
  self.assertIsNone(t1.tags)
@@ -72,6 +96,10 @@ class TestTestingConfig(TestCase):
72
96
  async def testInvalidVerbosity(self):
73
97
  """
74
98
  Test invalid verbosity values.
99
+
100
+ Notes
101
+ -----
102
+ Verifies that invalid verbosity values raise OrionisIntegrityException.
75
103
  """
76
104
  with self.assertRaises(OrionisIntegrityException):
77
105
  Testing(verbosity=-1)
@@ -83,6 +111,10 @@ class TestTestingConfig(TestCase):
83
111
  async def testInvalidExecutionMode(self):
84
112
  """
85
113
  Test execution_mode cannot be None.
114
+
115
+ Notes
116
+ -----
117
+ Ensures that setting execution_mode to None raises OrionisIntegrityException.
86
118
  """
87
119
  with self.assertRaises(OrionisIntegrityException):
88
120
  Testing(execution_mode=None)
@@ -90,6 +122,10 @@ class TestTestingConfig(TestCase):
90
122
  async def testInvalidMaxWorkers(self):
91
123
  """
92
124
  Test invalid max_workers values.
125
+
126
+ Notes
127
+ -----
128
+ Checks that invalid values for max_workers raise OrionisIntegrityException.
93
129
  """
94
130
  with self.assertRaises(OrionisIntegrityException):
95
131
  Testing(max_workers=0)
@@ -101,6 +137,10 @@ class TestTestingConfig(TestCase):
101
137
  async def testInvalidFailFast(self):
102
138
  """
103
139
  Test fail_fast must be boolean.
140
+
141
+ Notes
142
+ -----
143
+ Ensures that non-boolean values for fail_fast raise OrionisIntegrityException.
104
144
  """
105
145
  with self.assertRaises(OrionisIntegrityException):
106
146
  Testing(fail_fast="yes")
@@ -108,6 +148,10 @@ class TestTestingConfig(TestCase):
108
148
  async def testInvalidPrintResult(self):
109
149
  """
110
150
  Test print_result must be boolean.
151
+
152
+ Notes
153
+ -----
154
+ Ensures that non-boolean values for print_result raise OrionisIntegrityException.
111
155
  """
112
156
  with self.assertRaises(OrionisIntegrityException):
113
157
  Testing(print_result=1)
@@ -115,6 +159,10 @@ class TestTestingConfig(TestCase):
115
159
  async def testInvalidThrowException(self):
116
160
  """
117
161
  Test throw_exception must be boolean.
162
+
163
+ Notes
164
+ -----
165
+ Ensures that non-boolean values for throw_exception raise OrionisIntegrityException.
118
166
  """
119
167
  with self.assertRaises(OrionisIntegrityException):
120
168
  Testing(throw_exception="no")
@@ -122,6 +170,10 @@ class TestTestingConfig(TestCase):
122
170
  async def testInvalidBasePath(self):
123
171
  """
124
172
  Test base_path must be string.
173
+
174
+ Notes
175
+ -----
176
+ Ensures that non-string values for base_path raise OrionisIntegrityException.
125
177
  """
126
178
  with self.assertRaises(OrionisIntegrityException):
127
179
  Testing(base_path=123)
@@ -129,6 +181,10 @@ class TestTestingConfig(TestCase):
129
181
  async def testInvalidFolderPath(self):
130
182
  """
131
183
  Test folder_path must be string or list of strings.
184
+
185
+ Notes
186
+ -----
187
+ Ensures that invalid types for folder_path raise OrionisIntegrityException.
132
188
  """
133
189
  with self.assertRaises(OrionisIntegrityException):
134
190
  Testing(folder_path=123)
@@ -140,6 +196,10 @@ class TestTestingConfig(TestCase):
140
196
  async def testInvalidPattern(self):
141
197
  """
142
198
  Test pattern must be string.
199
+
200
+ Notes
201
+ -----
202
+ Ensures that non-string values for pattern raise OrionisIntegrityException.
143
203
  """
144
204
  with self.assertRaises(OrionisIntegrityException):
145
205
  Testing(pattern=[])
@@ -149,6 +209,10 @@ class TestTestingConfig(TestCase):
149
209
  async def testInvalidTestNamePattern(self):
150
210
  """
151
211
  Test test_name_pattern must be string or None.
212
+
213
+ Notes
214
+ -----
215
+ Ensures that invalid types for test_name_pattern raise OrionisIntegrityException.
152
216
  """
153
217
  with self.assertRaises(OrionisIntegrityException):
154
218
  Testing(test_name_pattern=[])
@@ -158,6 +222,10 @@ class TestTestingConfig(TestCase):
158
222
  async def testInvalidTags(self):
159
223
  """
160
224
  Test tags must be None or list of strings.
225
+
226
+ Notes
227
+ -----
228
+ Ensures that invalid types for tags raise OrionisIntegrityException.
161
229
  """
162
230
  with self.assertRaises(OrionisIntegrityException):
163
231
  Testing(tags="fast")
@@ -2,10 +2,19 @@ from orionis.patterns.singleton.meta_class import Singleton
2
2
  from orionis.test.cases.test_case import TestCase
3
3
 
4
4
  class TestsAsyncCoroutine(TestCase):
5
+ """
6
+ Test cases for the Singleton metaclass.
7
+
8
+ This class contains asynchronous test methods to verify the correct behavior
9
+ of the Singleton metaclass, ensuring that only one instance of a class is created.
10
+ """
5
11
 
6
12
  async def testSingleton(self):
7
13
  """
8
- Test the Singleton metaclass to ensure that only one instance of a class is created.
14
+ Test the Singleton metaclass.
15
+
16
+ Ensures that only one instance of a class using the Singleton metaclass is created,
17
+ regardless of how many times the class is instantiated.
9
18
  """
10
19
  class SingletonClass(metaclass=Singleton):
11
20
  def __init__(self, value):
@@ -12,10 +12,9 @@ class TestEnv(TestCase):
12
12
  Test that the get method retrieves values correctly.
13
13
  Verifies that Env.get() properly delegates to DotEnv.get() and returns the expected value.
14
14
  """
15
- with unittest_mock_patch.object(DotEnv, 'get', return_value='test_value') as mock_get:
16
- result = Env.get('TEST_KEY')
17
- mock_get.assert_called_once_with('TEST_KEY', None, False)
18
- self.assertEqual(result, 'test_value')
15
+
16
+ # Set test key in.env
17
+ Env.set('TEST_KEY', 'test_value')
19
18
 
20
19
  async def testGetMethodWithDefault(self):
21
20
  """
@@ -1,16 +1,25 @@
1
-
2
1
  from orionis.unittesting import TestCase, TestResult, TestStatus
3
2
 
4
3
  class TestTestResult(TestCase):
5
- """
6
- Test cases for the TestResult dataclass.
7
- """
8
4
 
9
- async def testDefaultValues(self):
5
+ async def testDefaultValues(self) -> None:
10
6
  """
11
- Test that TestResult initializes with correct default values for optional fields.
7
+ Ensures that when optional fields are not provided during initialization of a TestResult
8
+ instance, they are set to None.
9
+
10
+ Notes
11
+ -----
12
+ This test verifies the default behavior of the following optional fields:
13
+ - error_message
14
+ - traceback
15
+ - class_name
16
+ - method
17
+ - module
18
+ - file_path
12
19
 
13
- Verifies that optional fields are None when not provided during initialization.
20
+ Assertions
21
+ ----------
22
+ Each optional field is checked to confirm it is None after initialization.
14
23
  """
15
24
  result = TestResult(
16
25
  id=1,
@@ -25,11 +34,16 @@ class TestTestResult(TestCase):
25
34
  self.assertIsNone(result.module)
26
35
  self.assertIsNone(result.file_path)
27
36
 
28
- async def testRequiredFields(self):
37
+ async def testRequiredFields(self) -> None:
29
38
  """
30
- Test that TestResult requires all non-optional fields during initialization.
39
+ Test that TestResult enforces the presence of all required (non-optional) fields during initialization.
40
+ This test verifies that omitting any required field when creating a TestResult instance raises a TypeError.
31
41
 
32
- Ensures that missing any required field raises a TypeError.
42
+ Notes
43
+ -----
44
+ - Attempts to instantiate TestResult with no arguments.
45
+ - Attempts to instantiate TestResult missing the 'id' field.
46
+ - Expects a TypeError to be raised in both cases.
33
47
  """
34
48
  with self.assertRaises(TypeError):
35
49
  TestResult() # Missing all required fields
@@ -42,11 +56,21 @@ class TestTestResult(TestCase):
42
56
  execution_time=0.5
43
57
  )
44
58
 
45
- async def testImmutable(self):
59
+ async def testImmutable(self) -> None:
46
60
  """
47
- Test that TestResult instances are immutable (frozen dataclass).
61
+ Test the immutability of TestResult instances.
62
+ This test ensures that TestResult, implemented as a frozen dataclass, does not allow
63
+ modification of its attributes after instantiation.
64
+
65
+ Parameters
66
+ ----------
67
+ self : TestCase
68
+ The test case instance.
48
69
 
49
- Verifies that attribute modification after creation raises a FrozenInstanceError.
70
+ Raises
71
+ ------
72
+ FrozenInstanceError
73
+ If an attempt is made to modify an attribute of a frozen TestResult instance.
50
74
  """
51
75
  result = TestResult(
52
76
  id=1,
@@ -57,11 +81,18 @@ class TestTestResult(TestCase):
57
81
  with self.assertRaises(Exception):
58
82
  result.name = "Modified Name"
59
83
 
60
- async def testStatusValues(self):
84
+ async def testStatusValues(self) -> None:
61
85
  """
62
- Test that TestResult correctly handles all possible TestStatus values.
86
+ Parameters
87
+ ----------
88
+ self : TestCase
89
+ The test case instance.
63
90
 
64
- Verifies that all enum values can be assigned to the status field.
91
+ Notes
92
+ -----
93
+ This test iterates over all possible values of the `TestStatus` enum and verifies
94
+ that each value can be assigned to the `status` field of a `TestResult` instance.
95
+ It asserts that the assigned status matches the expected value.
65
96
  """
66
97
  for status in TestStatus:
67
98
  result = TestResult(
@@ -72,11 +103,17 @@ class TestTestResult(TestCase):
72
103
  )
73
104
  self.assertEqual(result.status, status)
74
105
 
75
- async def testErrorFields(self):
106
+ async def testErrorFields(self) -> None:
76
107
  """
77
- Test that error-related fields are properly stored when provided.
108
+ Parameters
109
+ ----------
110
+ self : TestCase
111
+ The test case instance.
78
112
 
79
- Verifies that error_message and traceback are stored correctly when provided.
113
+ Notes
114
+ -----
115
+ Verifies that the `error_message` and `traceback` fields are correctly stored in the `TestResult`
116
+ object when provided during initialization.
80
117
  """
81
118
  error_msg = "Test failed"
82
119
  traceback = "Traceback info"
@@ -2,13 +2,13 @@ from orionis.test.cases.test_case import TestCase
2
2
  from orionis.unittesting import UnitTest, ExecutionMode, UnittestTestLoader, UnittestTestSuite, unittest_mock_patch, UnittestMagicMock, UnittestTestResult
3
3
 
4
4
  class TestUnitTest(TestCase):
5
- """
6
- Test cases for the UnitTest class which handles test discovery and execution.
7
- """
8
5
 
9
- async def testDefaultConfiguration(self):
6
+ async def testDefaultConfiguration(self) -> None:
10
7
  """
11
8
  Test that UnitTest initializes with correct default configuration values.
9
+
10
+ Notes
11
+ -----
12
12
  Verifies that all default attributes are set as expected upon initialization.
13
13
  """
14
14
  unit_test = UnitTest()
@@ -20,10 +20,28 @@ class TestUnitTest(TestCase):
20
20
  self.assertIsInstance(unit_test.loader, UnittestTestLoader)
21
21
  self.assertIsInstance(unit_test.suite, UnittestTestSuite)
22
22
 
23
- async def testConfigureMethod(self):
24
- """
25
- Test that configure method properly updates configuration values.
26
- Verifies that all configuration parameters can be updated through the configure method.
23
+ async def testConfigureMethod(self) -> None:
24
+ """
25
+ Test the `configure` method for correct configuration updates.
26
+ This test verifies that all configuration parameters of the `UnitTest` class
27
+ can be updated through the `configure` method and that the changes are
28
+ reflected in the instance attributes.
29
+
30
+ Parameters
31
+ ----------
32
+ self : TestCase
33
+ The test case instance.
34
+
35
+ Notes
36
+ -----
37
+ The test checks the following configuration parameters:
38
+ - verbosity
39
+ - execution_mode
40
+ - max_workers
41
+ - fail_fast
42
+ - print_result
43
+ - throw_exception
44
+ It also asserts that the `configure` method returns the instance itself.
27
45
  """
28
46
  unit_test = UnitTest()
29
47
  configured = unit_test.configure(
@@ -43,10 +61,17 @@ class TestUnitTest(TestCase):
43
61
  self.assertTrue(unit_test.throw_exception)
44
62
  self.assertEqual(configured, unit_test)
45
63
 
46
- async def testDiscoverTestsInModule(self):
64
+ async def testDiscoverTestsInModule(self) -> None:
47
65
  """
48
- Test that discoverTestsInModule correctly loads tests from a module.
66
+ Test that `discoverTestsInModule` correctly loads tests from a module.
67
+
49
68
  Verifies that tests can be discovered from a module and added to the test suite.
69
+
70
+ Notes
71
+ -----
72
+ This test mocks the loader's `loadTestsFromName` method to ensure that
73
+ `discoverTestsInModule` calls it with the correct arguments and that the
74
+ returned suite is handled as expected.
50
75
  """
51
76
  unit_test = UnitTest()
52
77
  with unittest_mock_patch.object(unit_test.loader, 'loadTestsFromName') as mock_load:
@@ -57,11 +82,22 @@ class TestUnitTest(TestCase):
57
82
  self.assertEqual(result, unit_test)
58
83
  self.assertEqual(len(unit_test.suite._tests), 0)
59
84
 
60
- async def testFlattenTestSuite(self):
85
+ async def testFlattenTestSuite(self) -> None:
61
86
  """
62
- Test that _flattenTestSuite correctly flattens nested test suites.
87
+ Test the _flattenTestSuite method for correct flattening of nested test suites.
88
+ This test verifies that the _flattenTestSuite method of the UnitTest class
89
+ correctly flattens both simple and nested unittest suites into a single list
90
+ of test cases.
91
+
92
+ Parameters
93
+ ----------
94
+ self : TestCase
95
+ The test case instance.
63
96
 
64
- Verifies that both simple and nested test suites are properly flattened.
97
+ Notes
98
+ -----
99
+ - Ensures that nested suites are recursively flattened.
100
+ - Asserts that all test cases from nested suites are present in the flattened result.
65
101
  """
66
102
  unit_test = UnitTest()
67
103
  test_case1 = UnittestMagicMock()
@@ -79,11 +115,16 @@ class TestUnitTest(TestCase):
79
115
  self.assertIn(test_case1, flattened)
80
116
  self.assertIn(test_case2, flattened)
81
117
 
82
- async def testMergeTestResults(self):
118
+ async def testMergeTestResults(self) -> None:
83
119
  """
84
- Test that _mergeTestResults correctly combines test results.
120
+ Test the _mergeTestResults method for correct merging of test results.
121
+ Ensures that the method accurately combines the number of tests run,
122
+ as well as the lists of failures and errors from individual test results.
85
123
 
86
- Verifies that test counts, failures, and errors are properly merged.
124
+ Notes
125
+ -----
126
+ - Verifies that the total number of tests run is updated correctly.
127
+ - Checks that failures and errors are merged without loss of information.
87
128
  """
88
129
  unit_test = UnitTest()
89
130
  combined = UnittestTestResult()
@@ -98,10 +139,22 @@ class TestUnitTest(TestCase):
98
139
  self.assertEqual(len(combined.failures), 1)
99
140
  self.assertEqual(len(combined.errors), 1)
100
141
 
101
- async def testClearTests(self):
142
+ async def testClearTests(self) -> None:
102
143
  """
103
- Test that clearTests method resets the test suite.
104
- Verifies that the test suite is emptied when clearTests is called.
144
+ Test the clearTests method to ensure it resets the test suite.
145
+ This test verifies that after adding a mock test to the suite and calling
146
+ the clearTests method, the suite is emptied as expected.
147
+
148
+ Steps
149
+ -----
150
+ 1. Create an instance of UnitTest.
151
+ 2. Add a mock test to the test suite.
152
+ 3. Call the clearTests method.
153
+ 4. Assert that the test suite is empty.
154
+
155
+ Assertions
156
+ ----------
157
+ - The length of the test suite should be zero after calling clearTests.
105
158
  """
106
159
  unit_test = UnitTest()
107
160
  mock_test = UnittestMagicMock()
@@ -110,10 +163,16 @@ class TestUnitTest(TestCase):
110
163
  unit_test.clearTests()
111
164
  self.assertEqual(len(unit_test.suite._tests), 0)
112
165
 
113
- async def testGetTestNames(self):
166
+ async def testGetTestNames(self) -> None:
114
167
  """
115
- Test that getTestNames returns correct test identifiers.
116
- Verifies that test names are properly extracted from the test suite.
168
+ This test verifies that the `getTestNames` method of the `UnitTest` class
169
+ correctly extracts and returns the identifiers of tests present in the test suite.
170
+
171
+ Notes
172
+ -----
173
+ - Mocks a test case with a predefined identifier.
174
+ - Adds the mock test to the test suite.
175
+ - Asserts that the returned list of test names matches the expected value.
117
176
  """
118
177
  unit_test = UnitTest()
119
178
  mock_test = UnittestMagicMock()
@@ -123,10 +182,20 @@ class TestUnitTest(TestCase):
123
182
  names = unit_test.getTestNames()
124
183
  self.assertEqual(names, ['test_id'])
125
184
 
126
- async def testGetTestCount(self):
185
+ async def testGetTestCount(self) -> None:
127
186
  """
128
- Test that getTestCount returns the correct number of tests.
187
+ Test that `getTestCount` returns the correct number of tests.
188
+
129
189
  Verifies that the count matches the number of tests in the suite.
190
+
191
+ Notes
192
+ -----
193
+ - Adds two mock tests to the suite.
194
+ - Asserts that `getTestCount` returns 2.
195
+
196
+ Returns
197
+ -------
198
+ None
130
199
  """
131
200
  unit_test = UnitTest()
132
201
  mock_test1 = UnittestMagicMock()