orionis 0.546.0__py3-none-any.whl → 0.548.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/console/base/scheduler_event_listener.py +0 -17
- orionis/console/contracts/schedule_event_listener.py +0 -18
- orionis/foundation/config/app/entities/app.py +3 -2
- orionis/foundation/config/app/enums/ciphers.py +5 -19
- orionis/foundation/config/session/entities/session.py +2 -2
- orionis/metadata/framework.py +1 -1
- orionis/services/encrypter/encrypter.py +115 -0
- orionis/services/environment/dynamic/caster.py +35 -27
- orionis/services/environment/key/key_generator.py +32 -11
- {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/METADATA +1 -1
- {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/RECORD +14 -159
- {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/top_level.txt +0 -1
- orionis-0.546.0.dist-info/zip-safe +0 -1
- tests/container/__init__.py +0 -0
- tests/container/context/__init__.py +0 -0
- tests/container/context/test_manager.py +0 -38
- tests/container/context/test_scope.py +0 -32
- tests/container/core/__init__.py +0 -0
- tests/container/core/test_advanced_async.py +0 -234
- tests/container/core/test_async_optimizations.py +0 -268
- tests/container/core/test_container.py +0 -453
- tests/container/core/test_singleton.py +0 -122
- tests/container/core/test_thread_safety.py +0 -90
- tests/container/entities/__init__.py +0 -0
- tests/container/entities/test_binding.py +0 -242
- tests/container/enums/__init__.py +0 -0
- tests/container/enums/test_lifetimes.py +0 -97
- tests/container/facades/__init__.py +0 -0
- tests/container/facades/test_facade.py +0 -78
- tests/container/mocks/__init__.py +0 -0
- tests/container/mocks/mock_advanced_async.py +0 -332
- tests/container/mocks/mock_async_optimizations.py +0 -407
- tests/container/mocks/mock_auto_resolution.py +0 -192
- tests/container/mocks/mock_complex_classes.py +0 -792
- tests/container/mocks/mock_simple_classes.py +0 -98
- tests/container/providers/__init__.py +0 -0
- tests/container/providers/test_providers.py +0 -55
- tests/container/validators/__init__.py +0 -0
- tests/container/validators/test_implements.py +0 -186
- tests/container/validators/test_is_abstract_class.py +0 -147
- tests/container/validators/test_is_callable.py +0 -102
- tests/container/validators/test_is_concrete_class.py +0 -160
- tests/container/validators/test_is_instance.py +0 -150
- tests/container/validators/test_is_not_subclass.py +0 -49
- tests/container/validators/test_is_subclass.py +0 -178
- tests/container/validators/test_is_valid_alias.py +0 -147
- tests/container/validators/test_lifetime.py +0 -106
- tests/example/__init__.py +0 -0
- tests/example/test_example.py +0 -725
- tests/foundation/__init__.py +0 -0
- tests/foundation/config/__init__.py +0 -0
- tests/foundation/config/app/__init__.py +0 -0
- tests/foundation/config/app/test_foundation_config_app.py +0 -262
- tests/foundation/config/auth/__init__.py +0 -0
- tests/foundation/config/auth/test_foundation_config_auth.py +0 -29
- tests/foundation/config/cache/__init__.py +0 -0
- tests/foundation/config/cache/test_foundation_config_cache.py +0 -143
- tests/foundation/config/cache/test_foundation_config_cache_file.py +0 -126
- tests/foundation/config/cache/test_foundation_config_cache_stores.py +0 -156
- tests/foundation/config/cors/__init__.py +0 -0
- tests/foundation/config/cors/test_foundation_config_cors.py +0 -190
- tests/foundation/config/database/__init__.py +0 -0
- tests/foundation/config/database/test_foundation_config_database.py +0 -158
- tests/foundation/config/database/test_foundation_config_database_connections.py +0 -203
- tests/foundation/config/database/test_foundation_config_database_mysql.py +0 -354
- tests/foundation/config/database/test_foundation_config_database_oracle.py +0 -288
- tests/foundation/config/database/test_foundation_config_database_pgsql.py +0 -257
- tests/foundation/config/database/test_foundation_config_database_sqlite.py +0 -207
- tests/foundation/config/filesystems/__init__.py +0 -0
- tests/foundation/config/filesystems/test_foundation_config_filesystems.py +0 -160
- tests/foundation/config/filesystems/test_foundation_config_filesystems_aws.py +0 -189
- tests/foundation/config/filesystems/test_foundation_config_filesystems_disks.py +0 -184
- tests/foundation/config/filesystems/test_foundation_config_filesystems_local.py +0 -143
- tests/foundation/config/filesystems/test_foundation_config_filesystems_public.py +0 -184
- tests/foundation/config/logging/__init__.py +0 -0
- tests/foundation/config/logging/test_foundation_config_logging.py +0 -112
- tests/foundation/config/logging/test_foundation_config_logging_channels.py +0 -246
- tests/foundation/config/logging/test_foundation_config_logging_chunked.py +0 -217
- tests/foundation/config/logging/test_foundation_config_logging_daily.py +0 -220
- tests/foundation/config/logging/test_foundation_config_logging_hourly.py +0 -196
- tests/foundation/config/logging/test_foundation_config_logging_monthly.py +0 -214
- tests/foundation/config/logging/test_foundation_config_logging_stack.py +0 -178
- tests/foundation/config/logging/test_foundation_config_logging_weekly.py +0 -224
- tests/foundation/config/mail/__init__.py +0 -0
- tests/foundation/config/mail/test_foundation_config_mail.py +0 -145
- tests/foundation/config/mail/test_foundation_config_mail_file.py +0 -97
- tests/foundation/config/mail/test_foundation_config_mail_mailers.py +0 -106
- tests/foundation/config/mail/test_foundation_config_mail_smtp.py +0 -146
- tests/foundation/config/queue/__init__.py +0 -0
- tests/foundation/config/queue/test_foundation_config_queue.py +0 -88
- tests/foundation/config/queue/test_foundation_config_queue_brokers.py +0 -72
- tests/foundation/config/queue/test_foundation_config_queue_database.py +0 -134
- tests/foundation/config/root/__init__.py +0 -0
- tests/foundation/config/root/test_foundation_config_root_paths.py +0 -112
- tests/foundation/config/session/__init__.py +0 -0
- tests/foundation/config/session/test_foundation_config_session.py +0 -213
- tests/foundation/config/startup/__init__.py +0 -0
- tests/foundation/config/startup/test_foundation_config_startup.py +0 -202
- tests/foundation/config/testing/__init__.py +0 -0
- tests/foundation/config/testing/test_foundation_config_testing.py +0 -235
- tests/metadata/__init__.py +0 -0
- tests/metadata/test_metadata_framework.py +0 -140
- tests/metadata/test_metadata_package.py +0 -139
- tests/services/__init__.py +0 -0
- tests/services/asynchrony/__init__.py +0 -0
- tests/services/asynchrony/test_services_asynchrony_coroutine.py +0 -85
- tests/services/environment/__init__.py +0 -0
- tests/services/environment/test_services_environment.py +0 -226
- tests/services/introspection/__init__.py +0 -0
- tests/services/introspection/dependencies/__init__.py +0 -0
- tests/services/introspection/dependencies/mocks/__init__.py +0 -0
- tests/services/introspection/dependencies/mocks/mock_user.py +0 -30
- tests/services/introspection/dependencies/mocks/mock_user_controller.py +0 -27
- tests/services/introspection/dependencies/mocks/mock_users_permissions.py +0 -41
- tests/services/introspection/dependencies/test_reflect_dependencies.py +0 -261
- tests/services/introspection/reflection/__init__.py +0 -0
- tests/services/introspection/reflection/mock/__init__.py +0 -0
- tests/services/introspection/reflection/mock/fake_reflect_instance.py +0 -1115
- tests/services/introspection/reflection/test_reflection_abstract.py +0 -1011
- tests/services/introspection/reflection/test_reflection_callable.py +0 -206
- tests/services/introspection/reflection/test_reflection_concrete.py +0 -952
- tests/services/introspection/reflection/test_reflection_instance.py +0 -1233
- tests/services/introspection/reflection/test_reflection_module.py +0 -567
- tests/services/introspection/test_reflection.py +0 -462
- tests/services/log/__init__.py +0 -0
- tests/services/log/test_log.py +0 -97
- tests/services/system/__init__.py +0 -0
- tests/services/system/test_services_system_imports.py +0 -204
- tests/services/system/test_services_system_workers.py +0 -131
- tests/support/__init__.py +0 -0
- tests/support/entities/__init__.py +0 -0
- tests/support/entities/mock_dataclass.py +0 -40
- tests/support/entities/test_base.py +0 -64
- tests/support/patterns/__init__.py +0 -0
- tests/support/patterns/singleton/__init__.py +0 -0
- tests/support/patterns/singleton/test_patterns_singleton.py +0 -39
- tests/support/standard/__init__.py +0 -0
- tests/support/standard/test_services_std.py +0 -226
- tests/support/wrapper/__init__.py +0 -0
- tests/support/wrapper/test_services_wrapper_docdict.py +0 -202
- tests/testing/__init__.py +0 -0
- tests/testing/cases/__init__.py +0 -0
- tests/testing/cases/test_testing_asynchronous.py +0 -63
- tests/testing/cases/test_testing_synchronous.py +0 -57
- tests/testing/entities/__init__.py +0 -0
- tests/testing/entities/test_testing_result.py +0 -146
- tests/testing/enums/__init__.py +0 -0
- tests/testing/enums/test_testing_status.py +0 -63
- tests/testing/output/__init__.py +0 -0
- tests/testing/output/test_testing_dumper.py +0 -29
- tests/testing/output/test_testing_printer.py +0 -42
- tests/testing/records/__init__.py +0 -0
- tests/testing/records/test_testing_records.py +0 -171
- tests/testing/test_testing_unit.py +0 -164
- tests/testing/validators/__init__.py +0 -0
- tests/testing/validators/test_testing_validators.py +0 -392
- tests/testing/view/__init__.py +0 -0
- tests/testing/view/test_render.py +0 -30
- {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/WHEEL +0 -0
- {orionis-0.546.0.dist-info → orionis-0.548.0.dist-info}/licenses/LICENCE +0 -0
|
@@ -1,1233 +0,0 @@
|
|
|
1
|
-
from orionis.services.introspection.dependencies.entities.resolve_argument import ResolveArguments
|
|
2
|
-
from tests.services.introspection.reflection.mock.fake_reflect_instance import FakeClass
|
|
3
|
-
from orionis.services.introspection.instances.reflection import ReflectionInstance
|
|
4
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
5
|
-
|
|
6
|
-
class TestServiceReflectionInstance(AsyncTestCase):
|
|
7
|
-
|
|
8
|
-
async def testGetInstance(self):
|
|
9
|
-
"""
|
|
10
|
-
Test ReflectionInstance.getInstance() method functionality.
|
|
11
|
-
|
|
12
|
-
Verifies that the getInstance() method returns the wrapped instance object
|
|
13
|
-
correctly. Creates a ReflectionInstance wrapper around a FakeClass object
|
|
14
|
-
and validates that the retrieved instance maintains its original type.
|
|
15
|
-
|
|
16
|
-
Assertions
|
|
17
|
-
----------
|
|
18
|
-
- Retrieved instance is of type FakeClass
|
|
19
|
-
"""
|
|
20
|
-
reflect = ReflectionInstance(FakeClass())
|
|
21
|
-
instance = reflect.getInstance()
|
|
22
|
-
self.assertIsInstance(instance, FakeClass)
|
|
23
|
-
|
|
24
|
-
async def testGetClass(self):
|
|
25
|
-
"""
|
|
26
|
-
Test ReflectionInstance.getClass() method functionality.
|
|
27
|
-
|
|
28
|
-
Verifies that the getClass method correctly returns the class type
|
|
29
|
-
of the wrapped instance object. Creates a ReflectionInstance with
|
|
30
|
-
a FakeClass instance and validates the returned class type.
|
|
31
|
-
|
|
32
|
-
Assertions
|
|
33
|
-
----------
|
|
34
|
-
- Returned class equals FakeClass type
|
|
35
|
-
"""
|
|
36
|
-
reflect = ReflectionInstance(FakeClass())
|
|
37
|
-
cls = reflect.getClass()
|
|
38
|
-
self.assertEqual(cls, FakeClass)
|
|
39
|
-
|
|
40
|
-
async def testGetClassName(self):
|
|
41
|
-
"""
|
|
42
|
-
Test ReflectionInstance.getClassName() method functionality.
|
|
43
|
-
|
|
44
|
-
Verifies that the getClassName method correctly retrieves the string
|
|
45
|
-
name of the wrapped instance's class. Creates a ReflectionInstance
|
|
46
|
-
with a FakeClass object and validates the returned class name.
|
|
47
|
-
|
|
48
|
-
Assertions
|
|
49
|
-
----------
|
|
50
|
-
- Returned class name equals 'FakeClass'
|
|
51
|
-
"""
|
|
52
|
-
reflect = ReflectionInstance(FakeClass())
|
|
53
|
-
class_name = reflect.getClassName()
|
|
54
|
-
self.assertEqual(class_name, 'FakeClass')
|
|
55
|
-
|
|
56
|
-
async def testGetModuleName(self):
|
|
57
|
-
"""
|
|
58
|
-
Test ReflectionInstance.getModuleName() method functionality.
|
|
59
|
-
|
|
60
|
-
Verifies that the getModuleName method correctly returns the fully
|
|
61
|
-
qualified module name of the wrapped instance's class. Creates a
|
|
62
|
-
ReflectionInstance with a FakeClass object and validates the module path.
|
|
63
|
-
|
|
64
|
-
Assertions
|
|
65
|
-
----------
|
|
66
|
-
- Returned module name equals 'tests.services.introspection.reflection.mock.fake_reflect_instance'
|
|
67
|
-
"""
|
|
68
|
-
reflect = ReflectionInstance(FakeClass())
|
|
69
|
-
module_name = reflect.getModuleName()
|
|
70
|
-
self.assertEqual(module_name, 'tests.services.introspection.reflection.mock.fake_reflect_instance')
|
|
71
|
-
|
|
72
|
-
async def testGetModuleWithClassName(self):
|
|
73
|
-
"""
|
|
74
|
-
Test ReflectionInstance.getModuleWithClassName() method functionality.
|
|
75
|
-
|
|
76
|
-
Verifies that the getModuleWithClassName method returns the fully qualified
|
|
77
|
-
module path combined with the class name. Creates a ReflectionInstance
|
|
78
|
-
with a FakeClass object and validates the complete module.class path.
|
|
79
|
-
|
|
80
|
-
Assertions
|
|
81
|
-
----------
|
|
82
|
-
- Returned string equals 'tests.services.introspection.reflection.mock.fake_reflect_instance.FakeClass'
|
|
83
|
-
"""
|
|
84
|
-
reflect = ReflectionInstance(FakeClass())
|
|
85
|
-
module_with_class_name = reflect.getModuleWithClassName()
|
|
86
|
-
self.assertEqual(module_with_class_name, 'tests.services.introspection.reflection.mock.fake_reflect_instance.FakeClass')
|
|
87
|
-
|
|
88
|
-
async def testGetDocstring(self):
|
|
89
|
-
"""
|
|
90
|
-
Test ReflectionInstance.getDocstring() method functionality.
|
|
91
|
-
|
|
92
|
-
Verifies that the getDocstring method correctly retrieves the docstring
|
|
93
|
-
of the wrapped instance's class. Creates a ReflectionInstance with a
|
|
94
|
-
FakeClass object and compares the returned docstring with the class's __doc__.
|
|
95
|
-
|
|
96
|
-
Assertions
|
|
97
|
-
----------
|
|
98
|
-
- Returned docstring equals FakeClass.__doc__
|
|
99
|
-
"""
|
|
100
|
-
reflect = ReflectionInstance(FakeClass())
|
|
101
|
-
docstring = reflect.getDocstring()
|
|
102
|
-
self.assertEqual(docstring, FakeClass.__doc__)
|
|
103
|
-
|
|
104
|
-
async def testGetBaseClasses(self):
|
|
105
|
-
"""
|
|
106
|
-
Test ReflectionInstance.getBaseClasses() method functionality.
|
|
107
|
-
|
|
108
|
-
Verifies that the getBaseClasses method correctly retrieves the base
|
|
109
|
-
classes of the wrapped instance's class. Creates a ReflectionInstance
|
|
110
|
-
with a FakeClass object and validates that the base class is included.
|
|
111
|
-
|
|
112
|
-
Assertions
|
|
113
|
-
----------
|
|
114
|
-
- FakeClass.__base__ is present in the returned base classes list
|
|
115
|
-
"""
|
|
116
|
-
reflect = ReflectionInstance(FakeClass())
|
|
117
|
-
base_classes = reflect.getBaseClasses()
|
|
118
|
-
self.assertIn(FakeClass.__base__, base_classes)
|
|
119
|
-
|
|
120
|
-
async def testGetSourceCode(self):
|
|
121
|
-
"""
|
|
122
|
-
Test ReflectionInstance.getSourceCode() method functionality.
|
|
123
|
-
|
|
124
|
-
Verifies that the getSourceCode method correctly retrieves the source
|
|
125
|
-
code of the wrapped instance's class. Creates a ReflectionInstance
|
|
126
|
-
with a FakeClass object and validates the source code content.
|
|
127
|
-
|
|
128
|
-
Assertions
|
|
129
|
-
----------
|
|
130
|
-
- Returned source code starts with 'class FakeClass'
|
|
131
|
-
"""
|
|
132
|
-
reflect = ReflectionInstance(FakeClass())
|
|
133
|
-
source_code = reflect.getSourceCode()
|
|
134
|
-
self.assertTrue(source_code.startswith('class FakeClass'))
|
|
135
|
-
|
|
136
|
-
async def testGetFile(self):
|
|
137
|
-
"""
|
|
138
|
-
Test ReflectionInstance.getFile() method functionality.
|
|
139
|
-
|
|
140
|
-
Verifies that the getFile method correctly returns the file path
|
|
141
|
-
of the wrapped instance's class definition. Creates a ReflectionInstance
|
|
142
|
-
with a FakeClass object and validates the returned file path.
|
|
143
|
-
|
|
144
|
-
Assertions
|
|
145
|
-
----------
|
|
146
|
-
- Returned file path ends with 'fake_reflect_instance.py'
|
|
147
|
-
"""
|
|
148
|
-
reflect = ReflectionInstance(FakeClass())
|
|
149
|
-
file_path = reflect.getFile()
|
|
150
|
-
self.assertTrue(file_path.endswith('fake_reflect_instance.py'))
|
|
151
|
-
|
|
152
|
-
async def testGetAnnotations(self):
|
|
153
|
-
"""
|
|
154
|
-
Test ReflectionInstance.getAnnotations() method functionality.
|
|
155
|
-
|
|
156
|
-
Verifies that the getAnnotations method correctly returns the type
|
|
157
|
-
annotations of the wrapped instance's class. Creates a ReflectionInstance
|
|
158
|
-
with a FakeClass object and validates the presence of expected annotations.
|
|
159
|
-
|
|
160
|
-
Assertions
|
|
161
|
-
----------
|
|
162
|
-
- 'public_attr' annotation is present in the returned annotations
|
|
163
|
-
"""
|
|
164
|
-
reflect = ReflectionInstance(FakeClass())
|
|
165
|
-
annotations = reflect.getAnnotations()
|
|
166
|
-
self.assertIn('public_attr', annotations)
|
|
167
|
-
|
|
168
|
-
async def testHasAttribute(self):
|
|
169
|
-
"""
|
|
170
|
-
Test ReflectionInstance.hasAttribute() method functionality.
|
|
171
|
-
|
|
172
|
-
Verifies that the hasAttribute method correctly identifies the presence
|
|
173
|
-
or absence of attributes on the wrapped instance. Tests both existing
|
|
174
|
-
and non-existing attributes to validate proper boolean responses.
|
|
175
|
-
|
|
176
|
-
Assertions
|
|
177
|
-
----------
|
|
178
|
-
- Returns True for existing attribute 'public_attr'
|
|
179
|
-
- Returns False for non-existent attribute 'non_existent_attr'
|
|
180
|
-
"""
|
|
181
|
-
reflect = ReflectionInstance(FakeClass())
|
|
182
|
-
self.assertTrue(reflect.hasAttribute('public_attr'))
|
|
183
|
-
self.assertFalse(reflect.hasAttribute('non_existent_attr'))
|
|
184
|
-
|
|
185
|
-
async def testGetAttribute(self):
|
|
186
|
-
"""
|
|
187
|
-
Test ReflectionInstance.getAttribute() method functionality.
|
|
188
|
-
|
|
189
|
-
Verifies that the getAttribute method correctly retrieves attribute
|
|
190
|
-
values from the wrapped instance. Tests both existing attributes
|
|
191
|
-
and non-existent attributes to validate proper value retrieval.
|
|
192
|
-
|
|
193
|
-
Assertions
|
|
194
|
-
----------
|
|
195
|
-
- Returns correct value (42) for existing attribute 'public_attr'
|
|
196
|
-
- Returns None for non-existent attribute 'non_existent_attr'
|
|
197
|
-
"""
|
|
198
|
-
reflect = ReflectionInstance(FakeClass())
|
|
199
|
-
self.assertEqual(reflect.getAttribute('public_attr'), 42)
|
|
200
|
-
self.assertIsNone(reflect.getAttribute('non_existent_attr'))
|
|
201
|
-
|
|
202
|
-
async def testSetAttribute(self):
|
|
203
|
-
"""
|
|
204
|
-
Test ReflectionInstance.setAttribute() method functionality.
|
|
205
|
-
|
|
206
|
-
Verifies that the setAttribute method correctly sets attribute values
|
|
207
|
-
on the wrapped instance, including public, protected, and private attributes.
|
|
208
|
-
Also validates that the updated values can be retrieved using getAttribute.
|
|
209
|
-
|
|
210
|
-
Assertions
|
|
211
|
-
----------
|
|
212
|
-
- setAttribute returns True when setting public attribute 'name'
|
|
213
|
-
- Public attribute value is updated correctly to 'Orionis Framework'
|
|
214
|
-
- setAttribute returns True when setting protected attribute '_version'
|
|
215
|
-
- Protected attribute value is updated correctly to '1.x'
|
|
216
|
-
- setAttribute returns True when setting private attribute '__python'
|
|
217
|
-
- Private attribute value is updated correctly to '3.13+'
|
|
218
|
-
"""
|
|
219
|
-
reflect = ReflectionInstance(FakeClass())
|
|
220
|
-
self.assertTrue(reflect.setAttribute('name', 'Orionis Framework'))
|
|
221
|
-
self.assertEqual(reflect.getAttribute('name'), 'Orionis Framework')
|
|
222
|
-
self.assertTrue(reflect.setAttribute('_version', '1.x'))
|
|
223
|
-
self.assertEqual(reflect.getAttribute('_version'), '1.x')
|
|
224
|
-
self.assertTrue(reflect.setAttribute('__python', '3.13+'))
|
|
225
|
-
self.assertEqual(reflect.getAttribute('__python'), '3.13+')
|
|
226
|
-
|
|
227
|
-
async def testRemoveAttribute(self):
|
|
228
|
-
"""
|
|
229
|
-
Test ReflectionInstance.removeAttribute() method functionality.
|
|
230
|
-
|
|
231
|
-
Verifies that the removeAttribute method successfully removes an attribute
|
|
232
|
-
from the wrapped instance. Tests the removal process by first setting
|
|
233
|
-
an attribute, then removing it, and validating its absence.
|
|
234
|
-
|
|
235
|
-
Assertions
|
|
236
|
-
----------
|
|
237
|
-
- removeAttribute returns True when removing an existing attribute
|
|
238
|
-
- Attribute is no longer present after removal (hasAttribute returns False)
|
|
239
|
-
"""
|
|
240
|
-
reflect = ReflectionInstance(FakeClass())
|
|
241
|
-
reflect.setAttribute('new_attr', 100)
|
|
242
|
-
self.assertTrue(reflect.removeAttribute('new_attr'))
|
|
243
|
-
self.assertFalse(reflect.hasAttribute('new_attr'))
|
|
244
|
-
|
|
245
|
-
async def testGetAttributes(self):
|
|
246
|
-
"""
|
|
247
|
-
Test ReflectionInstance.getAttributes() method functionality.
|
|
248
|
-
|
|
249
|
-
Verifies that the getAttributes method correctly retrieves all attribute
|
|
250
|
-
names from the wrapped instance, including public, protected, and private
|
|
251
|
-
attributes. Tests comprehensive attribute visibility.
|
|
252
|
-
|
|
253
|
-
Assertions
|
|
254
|
-
----------
|
|
255
|
-
- 'public_attr' is present in the returned attributes list
|
|
256
|
-
- '_protected_attr' is present in the returned attributes list
|
|
257
|
-
- '__private_attr' is present in the returned attributes list
|
|
258
|
-
"""
|
|
259
|
-
reflect = ReflectionInstance(FakeClass())
|
|
260
|
-
attributes = reflect.getAttributes()
|
|
261
|
-
self.assertIn('public_attr', attributes)
|
|
262
|
-
self.assertIn('_protected_attr', attributes)
|
|
263
|
-
self.assertIn('__private_attr', attributes)
|
|
264
|
-
|
|
265
|
-
async def testGetPublicAttributes(self):
|
|
266
|
-
"""
|
|
267
|
-
Test ReflectionInstance.getPublicAttributes() method functionality.
|
|
268
|
-
|
|
269
|
-
Verifies that the getPublicAttributes method returns only public attributes
|
|
270
|
-
of the wrapped instance, excluding protected and private attributes. Tests
|
|
271
|
-
proper visibility filtering based on Python naming conventions.
|
|
272
|
-
|
|
273
|
-
Assertions
|
|
274
|
-
----------
|
|
275
|
-
- 'public_attr' is included in the returned list
|
|
276
|
-
- '_protected_attr' is not included in the returned list
|
|
277
|
-
- '__private_attr' is not included in the returned list
|
|
278
|
-
"""
|
|
279
|
-
reflect = ReflectionInstance(FakeClass())
|
|
280
|
-
public_attributes = reflect.getPublicAttributes()
|
|
281
|
-
self.assertIn('public_attr', public_attributes)
|
|
282
|
-
self.assertNotIn('_protected_attr', public_attributes)
|
|
283
|
-
self.assertNotIn('__private_attr', public_attributes)
|
|
284
|
-
|
|
285
|
-
async def testGetProtectedAttributes(self):
|
|
286
|
-
"""
|
|
287
|
-
Test ReflectionInstance.getProtectedAttributes() method functionality.
|
|
288
|
-
|
|
289
|
-
Verifies that the getProtectedAttributes method correctly identifies and
|
|
290
|
-
returns only protected attributes (prefixed with single underscore) of
|
|
291
|
-
the wrapped instance, excluding public and private attributes.
|
|
292
|
-
|
|
293
|
-
Assertions
|
|
294
|
-
----------
|
|
295
|
-
- '_protected_attr' is included in the returned list
|
|
296
|
-
- 'public_attr' is not included in the returned list
|
|
297
|
-
- '__private_attr' is not included in the returned list
|
|
298
|
-
"""
|
|
299
|
-
reflect = ReflectionInstance(FakeClass())
|
|
300
|
-
protected_attributes = reflect.getProtectedAttributes()
|
|
301
|
-
self.assertIn('_protected_attr', protected_attributes)
|
|
302
|
-
self.assertNotIn('public_attr', protected_attributes)
|
|
303
|
-
self.assertNotIn('__private_attr', protected_attributes)
|
|
304
|
-
|
|
305
|
-
async def testGetPrivateAttributes(self):
|
|
306
|
-
"""
|
|
307
|
-
Test ReflectionInstance.getPrivateAttributes() method functionality.
|
|
308
|
-
|
|
309
|
-
Verifies that the getPrivateAttributes method correctly identifies and
|
|
310
|
-
returns only private attributes (prefixed with double underscores) of
|
|
311
|
-
the wrapped instance, excluding public and protected attributes.
|
|
312
|
-
|
|
313
|
-
Assertions
|
|
314
|
-
----------
|
|
315
|
-
- '__private_attr' is included in the returned list
|
|
316
|
-
- 'public_attr' is not included in the returned list
|
|
317
|
-
- '_protected_attr' is not included in the returned list
|
|
318
|
-
"""
|
|
319
|
-
reflect = ReflectionInstance(FakeClass())
|
|
320
|
-
private_attributes = reflect.getPrivateAttributes()
|
|
321
|
-
self.assertIn('__private_attr', private_attributes)
|
|
322
|
-
self.assertNotIn('public_attr', private_attributes)
|
|
323
|
-
self.assertNotIn('_protected_attr', private_attributes)
|
|
324
|
-
|
|
325
|
-
async def testGetDunderAttributes(self):
|
|
326
|
-
"""
|
|
327
|
-
Test ReflectionInstance.getDunderAttributes() method functionality.
|
|
328
|
-
|
|
329
|
-
Verifies that the getDunderAttributes method correctly retrieves all
|
|
330
|
-
double underscore (dunder) attributes from the wrapped instance. Tests
|
|
331
|
-
the identification of special attributes with the dunder naming pattern.
|
|
332
|
-
|
|
333
|
-
Assertions
|
|
334
|
-
----------
|
|
335
|
-
- '__dd__' is present in the returned list of dunder attributes
|
|
336
|
-
"""
|
|
337
|
-
reflect = ReflectionInstance(FakeClass())
|
|
338
|
-
dunder_attributes = reflect.getDunderAttributes()
|
|
339
|
-
self.assertIn('__dd__', dunder_attributes)
|
|
340
|
-
|
|
341
|
-
async def testGetMagicAttributes(self):
|
|
342
|
-
"""
|
|
343
|
-
Test ReflectionInstance.getMagicAttributes() method functionality.
|
|
344
|
-
|
|
345
|
-
Verifies that the getMagicAttributes method returns a list of magic attributes
|
|
346
|
-
(special methods and attributes with double underscores) for the wrapped instance.
|
|
347
|
-
Tests the identification of Python magic/special attributes.
|
|
348
|
-
|
|
349
|
-
Assertions
|
|
350
|
-
----------
|
|
351
|
-
- '__dd__' is present in the returned list of magic attributes
|
|
352
|
-
"""
|
|
353
|
-
reflect = ReflectionInstance(FakeClass())
|
|
354
|
-
magic_attributes = reflect.getMagicAttributes()
|
|
355
|
-
self.assertIn('__dd__', magic_attributes)
|
|
356
|
-
|
|
357
|
-
async def testHasMethod(self):
|
|
358
|
-
"""
|
|
359
|
-
Test ReflectionInstance.hasMethod() method functionality.
|
|
360
|
-
|
|
361
|
-
Verifies that the hasMethod method correctly identifies the presence
|
|
362
|
-
or absence of methods on the wrapped instance. Tests both existing
|
|
363
|
-
and non-existing methods to validate proper boolean responses.
|
|
364
|
-
|
|
365
|
-
Assertions
|
|
366
|
-
----------
|
|
367
|
-
- Returns True for existing method 'instanceSyncMethod'
|
|
368
|
-
- Returns False for non-existent method 'non_existent_method'
|
|
369
|
-
"""
|
|
370
|
-
reflect = ReflectionInstance(FakeClass())
|
|
371
|
-
self.assertTrue(reflect.hasMethod('instanceSyncMethod'))
|
|
372
|
-
self.assertFalse(reflect.hasMethod('non_existent_method'))
|
|
373
|
-
|
|
374
|
-
async def testCallMethod(self):
|
|
375
|
-
"""
|
|
376
|
-
Test ReflectionInstance.callMethod() synchronous method functionality.
|
|
377
|
-
|
|
378
|
-
Verifies that the callMethod method correctly invokes synchronous methods
|
|
379
|
-
on the wrapped instance with arguments and returns the expected result.
|
|
380
|
-
Tests method execution through reflection with parameter passing.
|
|
381
|
-
|
|
382
|
-
Assertions
|
|
383
|
-
----------
|
|
384
|
-
- Calling 'instanceSyncMethod' with arguments 2 and 3 returns 5
|
|
385
|
-
"""
|
|
386
|
-
reflect = ReflectionInstance(FakeClass())
|
|
387
|
-
result = reflect.callMethod('instanceSyncMethod', 2, 3)
|
|
388
|
-
self.assertEqual(result, 5)
|
|
389
|
-
|
|
390
|
-
async def testCallAsyncMethod(self):
|
|
391
|
-
"""
|
|
392
|
-
Test ReflectionInstance.callMethod() asynchronous method functionality.
|
|
393
|
-
|
|
394
|
-
Verifies that the callMethod method correctly invokes asynchronous methods
|
|
395
|
-
on the wrapped instance with arguments and returns the expected result.
|
|
396
|
-
Tests async method execution through reflection with parameter passing.
|
|
397
|
-
|
|
398
|
-
Assertions
|
|
399
|
-
----------
|
|
400
|
-
- Calling 'instanceAsyncMethod' with arguments 2 and 3 returns 5
|
|
401
|
-
"""
|
|
402
|
-
reflect = ReflectionInstance(FakeClass())
|
|
403
|
-
result = await reflect.callMethod('instanceAsyncMethod', 2, 3)
|
|
404
|
-
self.assertEqual(result, 5)
|
|
405
|
-
|
|
406
|
-
async def testSetMethod(self):
|
|
407
|
-
"""
|
|
408
|
-
Test ReflectionInstance.setMethod() method functionality.
|
|
409
|
-
|
|
410
|
-
Verifies that the setMethod method can dynamically add both synchronous
|
|
411
|
-
and asynchronous methods to the wrapped instance. Tests the ability to
|
|
412
|
-
set custom methods and then call them through the reflection interface.
|
|
413
|
-
|
|
414
|
-
Assertions
|
|
415
|
-
----------
|
|
416
|
-
- Synchronous mock method returns expected result (5) when called with arguments 2 and 3
|
|
417
|
-
- Asynchronous mock method returns expected result (5) when called with arguments 2 and 3
|
|
418
|
-
"""
|
|
419
|
-
|
|
420
|
-
def mockSyncMethod(cls:FakeClass, num1, num2):
|
|
421
|
-
return num1 + num2
|
|
422
|
-
|
|
423
|
-
async def mockAsyncMethod(cls:FakeClass, num1, num2):
|
|
424
|
-
import asyncio
|
|
425
|
-
await asyncio.sleep(0.1)
|
|
426
|
-
return num1 + num2
|
|
427
|
-
|
|
428
|
-
reflect = ReflectionInstance(FakeClass())
|
|
429
|
-
reflect.setMethod('mockSyncMethodInstance', mockSyncMethod)
|
|
430
|
-
reflect.setMethod('mockAsyncMethodInstance', mockAsyncMethod)
|
|
431
|
-
sync_result = reflect.callMethod('mockSyncMethodInstance', 2, 3)
|
|
432
|
-
async_result = await reflect.callMethod('mockAsyncMethodInstance', 2, 3)
|
|
433
|
-
self.assertEqual(sync_result, 5)
|
|
434
|
-
self.assertEqual(async_result, 5)
|
|
435
|
-
|
|
436
|
-
async def testRemoveMethod(self):
|
|
437
|
-
"""
|
|
438
|
-
Test ReflectionInstance.removeMethod() method functionality.
|
|
439
|
-
|
|
440
|
-
Verifies that the removeMethod method can successfully remove dynamically
|
|
441
|
-
added methods from the wrapped instance. Tests the process of adding a
|
|
442
|
-
method, confirming its existence, removing it, and validating its absence.
|
|
443
|
-
|
|
444
|
-
Assertions
|
|
445
|
-
----------
|
|
446
|
-
- Method exists after being added (hasMethod returns True)
|
|
447
|
-
- Method no longer exists after removal (hasMethod returns False)
|
|
448
|
-
"""
|
|
449
|
-
def _testProtectedMethod(cls:FakeClass, x, y):
|
|
450
|
-
return x + y
|
|
451
|
-
|
|
452
|
-
def __testPrivateMethod(cls:FakeClass, x, y):
|
|
453
|
-
return x + y
|
|
454
|
-
|
|
455
|
-
reflect = ReflectionInstance(FakeClass())
|
|
456
|
-
reflect.setMethod('_testProtectedMethod', _testProtectedMethod)
|
|
457
|
-
self.assertTrue(reflect.hasMethod('_testProtectedMethod'))
|
|
458
|
-
reflect.removeMethod('_testProtectedMethod')
|
|
459
|
-
self.assertFalse(reflect.hasMethod('_testProtectedMethod'))
|
|
460
|
-
|
|
461
|
-
async def testGetMethodSignature(self):
|
|
462
|
-
"""
|
|
463
|
-
Test ReflectionInstance.getMethodSignature() method functionality.
|
|
464
|
-
|
|
465
|
-
Verifies that the getMethodSignature method correctly retrieves the
|
|
466
|
-
signature of a specified method from the wrapped instance. Tests
|
|
467
|
-
signature inspection and string representation of method parameters.
|
|
468
|
-
|
|
469
|
-
Assertions
|
|
470
|
-
----------
|
|
471
|
-
- Signature of 'instanceSyncMethod' equals '(self, x: int, y: int) -> int'
|
|
472
|
-
"""
|
|
473
|
-
reflect = ReflectionInstance(FakeClass())
|
|
474
|
-
signature = reflect.getMethodSignature('instanceSyncMethod')
|
|
475
|
-
self.assertEqual(str(signature), '(self, x: int, y: int) -> int')
|
|
476
|
-
|
|
477
|
-
async def testGetMethods(self):
|
|
478
|
-
"""
|
|
479
|
-
Test ReflectionInstance.getMethods() method functionality.
|
|
480
|
-
|
|
481
|
-
Verifies that the getMethods method correctly retrieves the names of all
|
|
482
|
-
instance methods from the wrapped instance, including both synchronous
|
|
483
|
-
and asynchronous methods. Tests comprehensive method discovery.
|
|
484
|
-
|
|
485
|
-
Assertions
|
|
486
|
-
----------
|
|
487
|
-
- 'instanceSyncMethod' is present in the returned methods list
|
|
488
|
-
- 'instanceAsyncMethod' is present in the returned methods list
|
|
489
|
-
"""
|
|
490
|
-
reflect = ReflectionInstance(FakeClass())
|
|
491
|
-
methods = reflect.getMethods()
|
|
492
|
-
self.assertIn('instanceSyncMethod', methods)
|
|
493
|
-
self.assertIn('instanceAsyncMethod', methods)
|
|
494
|
-
|
|
495
|
-
async def testGetPublicMethods(self):
|
|
496
|
-
"""
|
|
497
|
-
Test ReflectionInstance.getPublicMethods() method functionality.
|
|
498
|
-
|
|
499
|
-
Verifies that the getPublicMethods method returns only public methods
|
|
500
|
-
of the wrapped instance, excluding protected and private methods. Tests
|
|
501
|
-
method visibility filtering based on Python naming conventions.
|
|
502
|
-
|
|
503
|
-
Assertions
|
|
504
|
-
----------
|
|
505
|
-
- 'instanceSyncMethod' is included in the returned list
|
|
506
|
-
- '_protected_method' is not included in the returned list
|
|
507
|
-
- '__private_method' is not included in the returned list
|
|
508
|
-
"""
|
|
509
|
-
reflect = ReflectionInstance(FakeClass())
|
|
510
|
-
public_methods = reflect.getPublicMethods()
|
|
511
|
-
self.assertIn('instanceSyncMethod', public_methods)
|
|
512
|
-
self.assertNotIn('_protected_method', public_methods)
|
|
513
|
-
self.assertNotIn('__private_method', public_methods)
|
|
514
|
-
|
|
515
|
-
async def testGetPublicSyncMethods(self):
|
|
516
|
-
"""
|
|
517
|
-
Test ReflectionInstance.getPublicSyncMethods() method functionality.
|
|
518
|
-
|
|
519
|
-
Verifies that the getPublicSyncMethods method returns only the names of
|
|
520
|
-
public synchronous methods from the wrapped instance, excluding protected
|
|
521
|
-
and private methods. Tests synchronous method filtering with visibility.
|
|
522
|
-
|
|
523
|
-
Assertions
|
|
524
|
-
----------
|
|
525
|
-
- 'instanceSyncMethod' is included in the returned list
|
|
526
|
-
- '_protected_method' is not included in the returned list
|
|
527
|
-
- '__private_method' is not included in the returned list
|
|
528
|
-
"""
|
|
529
|
-
reflect = ReflectionInstance(FakeClass())
|
|
530
|
-
public_sync_methods = reflect.getPublicSyncMethods()
|
|
531
|
-
self.assertIn('instanceSyncMethod', public_sync_methods)
|
|
532
|
-
self.assertNotIn('_protected_method', public_sync_methods)
|
|
533
|
-
self.assertNotIn('__private_method', public_sync_methods)
|
|
534
|
-
|
|
535
|
-
async def testGetPublicAsyncMethods(self):
|
|
536
|
-
"""
|
|
537
|
-
Test ReflectionInstance.getPublicAsyncMethods() method functionality.
|
|
538
|
-
|
|
539
|
-
Verifies that the getPublicAsyncMethods method correctly identifies and
|
|
540
|
-
returns only public asynchronous methods from the wrapped instance,
|
|
541
|
-
excluding protected and private async methods.
|
|
542
|
-
|
|
543
|
-
Assertions
|
|
544
|
-
----------
|
|
545
|
-
- 'instanceAsyncMethod' is included in the returned list
|
|
546
|
-
- '_protected_async_method' is not included in the returned list
|
|
547
|
-
- '__private_async_method' is not included in the returned list
|
|
548
|
-
"""
|
|
549
|
-
reflect = ReflectionInstance(FakeClass())
|
|
550
|
-
public_async_methods = reflect.getPublicAsyncMethods()
|
|
551
|
-
self.assertIn('instanceAsyncMethod', public_async_methods)
|
|
552
|
-
self.assertNotIn('_protected_async_method', public_async_methods)
|
|
553
|
-
self.assertNotIn('__private_async_method', public_async_methods)
|
|
554
|
-
|
|
555
|
-
async def testGetProtectedMethods(self):
|
|
556
|
-
"""
|
|
557
|
-
Test ReflectionInstance.getProtectedMethods() method functionality.
|
|
558
|
-
|
|
559
|
-
Verifies that the getProtectedMethods method correctly identifies and
|
|
560
|
-
returns only protected methods (prefixed with single underscore) from
|
|
561
|
-
the wrapped instance, excluding public and private methods.
|
|
562
|
-
|
|
563
|
-
Assertions
|
|
564
|
-
----------
|
|
565
|
-
- '_protectedAsyncMethod' is included in the returned list
|
|
566
|
-
- 'instanceSyncMethod' is not included in the returned list
|
|
567
|
-
- '__privateSyncMethod' is not included in the returned list
|
|
568
|
-
"""
|
|
569
|
-
reflect = ReflectionInstance(FakeClass())
|
|
570
|
-
protected_methods = reflect.getProtectedMethods()
|
|
571
|
-
self.assertIn('_protectedAsyncMethod', protected_methods)
|
|
572
|
-
self.assertNotIn('instanceSyncMethod', protected_methods)
|
|
573
|
-
self.assertNotIn('__privateSyncMethod', protected_methods)
|
|
574
|
-
|
|
575
|
-
async def testGetProtectedSyncMethods(self):
|
|
576
|
-
"""
|
|
577
|
-
Test ReflectionInstance.getProtectedSyncMethods() method functionality.
|
|
578
|
-
|
|
579
|
-
Verifies that the getProtectedSyncMethods method correctly identifies and
|
|
580
|
-
returns only protected synchronous methods (prefixed with single underscore)
|
|
581
|
-
from the wrapped instance, excluding async and private methods.
|
|
582
|
-
|
|
583
|
-
Assertions
|
|
584
|
-
----------
|
|
585
|
-
- '_protectedsyncMethod' is included in the returned list
|
|
586
|
-
- 'instanceAsyncMethod' is not included in the returned list
|
|
587
|
-
- '__privateSyncMethod' is not included in the returned list
|
|
588
|
-
"""
|
|
589
|
-
reflect = ReflectionInstance(FakeClass())
|
|
590
|
-
protected_sync_methods = reflect.getProtectedSyncMethods()
|
|
591
|
-
self.assertIn('_protectedsyncMethod', protected_sync_methods)
|
|
592
|
-
self.assertNotIn('instanceAsyncMethod', protected_sync_methods)
|
|
593
|
-
self.assertNotIn('__privateSyncMethod', protected_sync_methods)
|
|
594
|
-
|
|
595
|
-
async def testGetProtectedAsyncMethods(self):
|
|
596
|
-
"""
|
|
597
|
-
Test ReflectionInstance.getProtectedAsyncMethods() method functionality.
|
|
598
|
-
|
|
599
|
-
Verifies that the getProtectedAsyncMethods method correctly identifies and
|
|
600
|
-
returns only protected asynchronous methods (prefixed with single underscore)
|
|
601
|
-
from the wrapped instance, excluding public and private methods.
|
|
602
|
-
|
|
603
|
-
Assertions
|
|
604
|
-
----------
|
|
605
|
-
- '_protectedAsyncMethod' is included in the returned list
|
|
606
|
-
- 'instanceSyncMethod' is not included in the returned list
|
|
607
|
-
- '__privateSyncMethod' is not included in the returned list
|
|
608
|
-
"""
|
|
609
|
-
reflect = ReflectionInstance(FakeClass())
|
|
610
|
-
protected_async_methods = reflect.getProtectedAsyncMethods()
|
|
611
|
-
self.assertIn('_protectedAsyncMethod', protected_async_methods)
|
|
612
|
-
self.assertNotIn('instanceSyncMethod', protected_async_methods)
|
|
613
|
-
self.assertNotIn('__privateSyncMethod', protected_async_methods)
|
|
614
|
-
|
|
615
|
-
async def testGetPrivateMethods(self):
|
|
616
|
-
"""
|
|
617
|
-
Test ReflectionInstance.getPrivateMethods() method functionality.
|
|
618
|
-
|
|
619
|
-
Verifies that the getPrivateMethods method correctly identifies and
|
|
620
|
-
returns only private methods (prefixed with double underscores) from
|
|
621
|
-
the wrapped instance, excluding public and protected methods.
|
|
622
|
-
|
|
623
|
-
Assertions
|
|
624
|
-
----------
|
|
625
|
-
- '__privateSyncMethod' is included in the returned list
|
|
626
|
-
- 'instanceSyncMethod' is not included in the returned list
|
|
627
|
-
- '_protectedAsyncMethod' is not included in the returned list
|
|
628
|
-
"""
|
|
629
|
-
reflect = ReflectionInstance(FakeClass())
|
|
630
|
-
private_methods = reflect.getPrivateMethods()
|
|
631
|
-
self.assertIn('__privateSyncMethod', private_methods)
|
|
632
|
-
self.assertNotIn('instanceSyncMethod', private_methods)
|
|
633
|
-
self.assertNotIn('_protectedAsyncMethod', private_methods)
|
|
634
|
-
|
|
635
|
-
async def testGetPrivateSyncMethods(self):
|
|
636
|
-
"""
|
|
637
|
-
Test ReflectionInstance.getPrivateSyncMethods() method functionality.
|
|
638
|
-
|
|
639
|
-
Verifies that the getPrivateSyncMethods method correctly identifies and
|
|
640
|
-
returns only private synchronous methods (prefixed with double underscores)
|
|
641
|
-
from the wrapped instance, excluding async and protected methods.
|
|
642
|
-
|
|
643
|
-
Assertions
|
|
644
|
-
----------
|
|
645
|
-
- '__privateSyncMethod' is included in the returned list
|
|
646
|
-
- 'instanceAsyncMethod' is not included in the returned list
|
|
647
|
-
- '_protectedAsyncMethod' is not included in the returned list
|
|
648
|
-
"""
|
|
649
|
-
reflect = ReflectionInstance(FakeClass())
|
|
650
|
-
private_sync_methods = reflect.getPrivateSyncMethods()
|
|
651
|
-
self.assertIn('__privateSyncMethod', private_sync_methods)
|
|
652
|
-
self.assertNotIn('instanceAsyncMethod', private_sync_methods)
|
|
653
|
-
self.assertNotIn('_protectedAsyncMethod', private_sync_methods)
|
|
654
|
-
|
|
655
|
-
async def testGetPrivateAsyncMethods(self):
|
|
656
|
-
"""
|
|
657
|
-
Test ReflectionInstance.getPrivateAsyncMethods() method functionality.
|
|
658
|
-
|
|
659
|
-
Verifies that the getPrivateAsyncMethods method correctly identifies and
|
|
660
|
-
returns only private asynchronous methods (prefixed with double underscores)
|
|
661
|
-
from the wrapped instance, excluding public and protected methods.
|
|
662
|
-
|
|
663
|
-
Assertions
|
|
664
|
-
----------
|
|
665
|
-
- '__privateAsyncMethod' is included in the returned list
|
|
666
|
-
- 'instanceSyncMethod' is not included in the returned list
|
|
667
|
-
- '_protectedAsyncMethod' is not included in the returned list
|
|
668
|
-
"""
|
|
669
|
-
reflect = ReflectionInstance(FakeClass())
|
|
670
|
-
private_async_methods = reflect.getPrivateAsyncMethods()
|
|
671
|
-
self.assertIn('__privateAsyncMethod', private_async_methods)
|
|
672
|
-
self.assertNotIn('instanceSyncMethod', private_async_methods)
|
|
673
|
-
self.assertNotIn('_protectedAsyncMethod', private_async_methods)
|
|
674
|
-
|
|
675
|
-
async def testGetPublicClassMethods(self):
|
|
676
|
-
"""
|
|
677
|
-
Test ReflectionInstance.getPublicClassMethods() method functionality.
|
|
678
|
-
|
|
679
|
-
Verifies that the getPublicClassMethods method correctly identifies and
|
|
680
|
-
returns only public class methods from the wrapped instance, excluding
|
|
681
|
-
protected and private class methods.
|
|
682
|
-
|
|
683
|
-
Assertions
|
|
684
|
-
----------
|
|
685
|
-
- 'classSyncMethod' is included in the returned list
|
|
686
|
-
- '_protected_class_method' is not included in the returned list
|
|
687
|
-
- '__private_class_method' is not included in the returned list
|
|
688
|
-
"""
|
|
689
|
-
reflect = ReflectionInstance(FakeClass())
|
|
690
|
-
public_class_methods = reflect.getPublicClassMethods()
|
|
691
|
-
self.assertIn('classSyncMethod', public_class_methods)
|
|
692
|
-
self.assertNotIn('_protected_class_method', public_class_methods)
|
|
693
|
-
self.assertNotIn('__private_class_method', public_class_methods)
|
|
694
|
-
|
|
695
|
-
async def testGetPublicClassSyncMethods(self):
|
|
696
|
-
"""
|
|
697
|
-
Test ReflectionInstance.getPublicClassSyncMethods() method functionality.
|
|
698
|
-
|
|
699
|
-
Verifies that the getPublicClassSyncMethods method correctly identifies and
|
|
700
|
-
returns only public synchronous class methods from the wrapped instance,
|
|
701
|
-
excluding protected and private class methods.
|
|
702
|
-
|
|
703
|
-
Assertions
|
|
704
|
-
----------
|
|
705
|
-
- 'classSyncMethod' is included in the returned list
|
|
706
|
-
- '_protected_class_method' is not included in the returned list
|
|
707
|
-
- '__private_class_method' is not included in the returned list
|
|
708
|
-
"""
|
|
709
|
-
reflect = ReflectionInstance(FakeClass())
|
|
710
|
-
public_class_sync_methods = reflect.getPublicClassSyncMethods()
|
|
711
|
-
self.assertIn('classSyncMethod', public_class_sync_methods)
|
|
712
|
-
self.assertNotIn('_protected_class_method', public_class_sync_methods)
|
|
713
|
-
self.assertNotIn('__private_class_method', public_class_sync_methods)
|
|
714
|
-
|
|
715
|
-
async def testGetPublicClassAsyncMethods(self):
|
|
716
|
-
"""
|
|
717
|
-
Test ReflectionInstance.getPublicClassAsyncMethods() method functionality.
|
|
718
|
-
|
|
719
|
-
Verifies that the getPublicClassAsyncMethods method correctly identifies and
|
|
720
|
-
returns only public asynchronous class methods from the wrapped instance,
|
|
721
|
-
excluding protected and private async class methods.
|
|
722
|
-
|
|
723
|
-
Assertions
|
|
724
|
-
----------
|
|
725
|
-
- 'classAsyncMethod' is included in the returned list
|
|
726
|
-
- '_protected_class_async_method' is not included in the returned list
|
|
727
|
-
- '__private_class_async_method' is not included in the returned list
|
|
728
|
-
"""
|
|
729
|
-
reflect = ReflectionInstance(FakeClass())
|
|
730
|
-
public_class_async_methods = reflect.getPublicClassAsyncMethods()
|
|
731
|
-
self.assertIn('classAsyncMethod', public_class_async_methods)
|
|
732
|
-
self.assertNotIn('_protected_class_async_method', public_class_async_methods)
|
|
733
|
-
self.assertNotIn('__private_class_async_method', public_class_async_methods)
|
|
734
|
-
|
|
735
|
-
async def testGetProtectedClassMethods(self):
|
|
736
|
-
"""
|
|
737
|
-
Test ReflectionInstance.getProtectedClassMethods() method functionality.
|
|
738
|
-
|
|
739
|
-
Verifies that the getProtectedClassMethods method correctly identifies and
|
|
740
|
-
returns only protected class methods (prefixed with single underscore) from
|
|
741
|
-
the wrapped instance, excluding public and private class methods.
|
|
742
|
-
|
|
743
|
-
Assertions
|
|
744
|
-
----------
|
|
745
|
-
- '_classMethodProtected' is included in the returned list
|
|
746
|
-
- 'classSyncMethod' is not included in the returned list
|
|
747
|
-
- '__classMethodPrivate' is not included in the returned list
|
|
748
|
-
"""
|
|
749
|
-
reflect = ReflectionInstance(FakeClass())
|
|
750
|
-
protected_class_methods = reflect.getProtectedClassMethods()
|
|
751
|
-
self.assertIn('_classMethodProtected', protected_class_methods)
|
|
752
|
-
self.assertNotIn('classSyncMethod', protected_class_methods)
|
|
753
|
-
self.assertNotIn('__classMethodPrivate', protected_class_methods)
|
|
754
|
-
|
|
755
|
-
async def testGetProtectedClassSyncMethods(self):
|
|
756
|
-
"""
|
|
757
|
-
Test ReflectionInstance.getProtectedClassSyncMethods() method functionality.
|
|
758
|
-
|
|
759
|
-
Verifies that the getProtectedClassSyncMethods method correctly identifies and
|
|
760
|
-
returns only protected synchronous class methods (prefixed with single underscore)
|
|
761
|
-
from the wrapped instance, excluding public and private class methods.
|
|
762
|
-
|
|
763
|
-
Assertions
|
|
764
|
-
----------
|
|
765
|
-
- '_classMethodProtected' is included in the returned list
|
|
766
|
-
- 'classSyncMethod' is not included in the returned list
|
|
767
|
-
- '__classSyncMethodPrivate' is not included in the returned list
|
|
768
|
-
"""
|
|
769
|
-
reflect = ReflectionInstance(FakeClass())
|
|
770
|
-
protected_class_sync_methods = reflect.getProtectedClassSyncMethods()
|
|
771
|
-
self.assertIn('_classMethodProtected', protected_class_sync_methods)
|
|
772
|
-
self.assertNotIn('classSyncMethod', protected_class_sync_methods)
|
|
773
|
-
self.assertNotIn('__classSyncMethodPrivate', protected_class_sync_methods)
|
|
774
|
-
|
|
775
|
-
async def testGetProtectedClassAsyncMethods(self):
|
|
776
|
-
"""
|
|
777
|
-
Test ReflectionInstance.getProtectedClassAsyncMethods() method functionality.
|
|
778
|
-
|
|
779
|
-
Verifies that the getProtectedClassAsyncMethods method correctly identifies and
|
|
780
|
-
returns only protected asynchronous class methods (prefixed with single underscore)
|
|
781
|
-
from the wrapped instance, excluding public and private async class methods.
|
|
782
|
-
|
|
783
|
-
Assertions
|
|
784
|
-
----------
|
|
785
|
-
- '_classAsyncMethodProtected' is included in the returned list
|
|
786
|
-
- 'classAsyncMethod' is not included in the returned list
|
|
787
|
-
- '__classAsyncMethodPrivate' is not included in the returned list
|
|
788
|
-
"""
|
|
789
|
-
reflect = ReflectionInstance(FakeClass())
|
|
790
|
-
protected_class_async_methods = reflect.getProtectedClassAsyncMethods()
|
|
791
|
-
self.assertIn('_classAsyncMethodProtected', protected_class_async_methods)
|
|
792
|
-
self.assertNotIn('classAsyncMethod', protected_class_async_methods)
|
|
793
|
-
self.assertNotIn('__classAsyncMethodPrivate', protected_class_async_methods)
|
|
794
|
-
|
|
795
|
-
async def testGetPrivateClassMethods(self):
|
|
796
|
-
"""
|
|
797
|
-
Test ReflectionInstance.getPrivateClassMethods() method functionality.
|
|
798
|
-
|
|
799
|
-
Verifies that the getPrivateClassMethods method correctly identifies and
|
|
800
|
-
returns only private class methods (prefixed with double underscores) from
|
|
801
|
-
the wrapped instance, excluding public and protected class methods.
|
|
802
|
-
|
|
803
|
-
Assertions
|
|
804
|
-
----------
|
|
805
|
-
- '__classMethodPrivate' is included in the returned list
|
|
806
|
-
- 'classSyncMethod' is not included in the returned list
|
|
807
|
-
- '_classMethodProtected' is not included in the returned list
|
|
808
|
-
"""
|
|
809
|
-
reflect = ReflectionInstance(FakeClass())
|
|
810
|
-
private_class_methods = reflect.getPrivateClassMethods()
|
|
811
|
-
self.assertIn('__classMethodPrivate', private_class_methods)
|
|
812
|
-
self.assertNotIn('classSyncMethod', private_class_methods)
|
|
813
|
-
self.assertNotIn('_classMethodProtected', private_class_methods)
|
|
814
|
-
|
|
815
|
-
async def testGetPrivateClassSyncMethods(self):
|
|
816
|
-
"""
|
|
817
|
-
Test ReflectionInstance.getPrivateClassSyncMethods() method functionality.
|
|
818
|
-
|
|
819
|
-
Verifies that the getPrivateClassSyncMethods method correctly identifies and
|
|
820
|
-
returns only private synchronous class methods (prefixed with double underscores)
|
|
821
|
-
from the wrapped instance, excluding public and protected class methods.
|
|
822
|
-
|
|
823
|
-
Assertions
|
|
824
|
-
----------
|
|
825
|
-
- '__classMethodPrivate' is included in the returned list
|
|
826
|
-
- 'classSyncMethod' is not included in the returned list
|
|
827
|
-
- '_classMethodProtected' is not included in the returned list
|
|
828
|
-
"""
|
|
829
|
-
reflect = ReflectionInstance(FakeClass())
|
|
830
|
-
private_class_methods = reflect.getPrivateClassSyncMethods()
|
|
831
|
-
self.assertIn('__classMethodPrivate', private_class_methods)
|
|
832
|
-
self.assertNotIn('classSyncMethod', private_class_methods)
|
|
833
|
-
self.assertNotIn('_classMethodProtected', private_class_methods)
|
|
834
|
-
|
|
835
|
-
async def testGetPrivateClassAsyncMethods(self):
|
|
836
|
-
"""
|
|
837
|
-
Test ReflectionInstance.getPrivateClassAsyncMethods() method functionality.
|
|
838
|
-
|
|
839
|
-
Verifies that the getPrivateClassAsyncMethods method correctly identifies and
|
|
840
|
-
returns only private asynchronous class methods (prefixed with double underscores)
|
|
841
|
-
from the wrapped instance, excluding public and protected async class methods.
|
|
842
|
-
|
|
843
|
-
Assertions
|
|
844
|
-
----------
|
|
845
|
-
- '__classAsyncMethodPrivate' is included in the returned list
|
|
846
|
-
- 'classAsyncMethod' is not included in the returned list
|
|
847
|
-
- '_classAsyncMethodProtected' is not included in the returned list
|
|
848
|
-
"""
|
|
849
|
-
reflect = ReflectionInstance(FakeClass())
|
|
850
|
-
private_class_async_methods = reflect.getPrivateClassAsyncMethods()
|
|
851
|
-
self.assertIn('__classAsyncMethodPrivate', private_class_async_methods)
|
|
852
|
-
self.assertNotIn('classAsyncMethod', private_class_async_methods)
|
|
853
|
-
self.assertNotIn('_classAsyncMethodProtected', private_class_async_methods)
|
|
854
|
-
|
|
855
|
-
async def testGetPublicStaticMethods(self):
|
|
856
|
-
"""
|
|
857
|
-
Test ReflectionInstance.getPublicStaticMethods() method functionality.
|
|
858
|
-
|
|
859
|
-
Verifies that the getPublicStaticMethods method correctly identifies and
|
|
860
|
-
returns the names of public static methods from the wrapped instance,
|
|
861
|
-
excluding protected and private static methods.
|
|
862
|
-
|
|
863
|
-
Assertions
|
|
864
|
-
----------
|
|
865
|
-
- 'staticMethod' is included in the returned list
|
|
866
|
-
- 'staticAsyncMethod' is included in the returned list
|
|
867
|
-
- 'static_async_method' is not included in the returned list
|
|
868
|
-
"""
|
|
869
|
-
reflect = ReflectionInstance(FakeClass())
|
|
870
|
-
public_static_methods = reflect.getPublicStaticMethods()
|
|
871
|
-
self.assertIn('staticMethod', public_static_methods)
|
|
872
|
-
self.assertIn('staticAsyncMethod', public_static_methods)
|
|
873
|
-
self.assertNotIn('static_async_method', public_static_methods)
|
|
874
|
-
|
|
875
|
-
async def testGetPublicStaticSyncMethods(self):
|
|
876
|
-
"""
|
|
877
|
-
Test ReflectionInstance.getPublicStaticSyncMethods() method functionality.
|
|
878
|
-
|
|
879
|
-
Verifies that the getPublicStaticSyncMethods method correctly identifies and
|
|
880
|
-
returns only public static synchronous methods from the wrapped instance,
|
|
881
|
-
excluding async and non-public static methods.
|
|
882
|
-
|
|
883
|
-
Assertions
|
|
884
|
-
----------
|
|
885
|
-
- 'staticMethod' is included in the returned list
|
|
886
|
-
- 'staticAsyncMethod' is not included in the returned list
|
|
887
|
-
- 'static_async_method' is not included in the returned list
|
|
888
|
-
"""
|
|
889
|
-
reflect = ReflectionInstance(FakeClass())
|
|
890
|
-
public_static_sync_methods = reflect.getPublicStaticSyncMethods()
|
|
891
|
-
self.assertIn('staticMethod', public_static_sync_methods)
|
|
892
|
-
self.assertNotIn('staticAsyncMethod', public_static_sync_methods)
|
|
893
|
-
self.assertNotIn('static_async_method', public_static_sync_methods)
|
|
894
|
-
|
|
895
|
-
async def testGetPublicStaticAsyncMethods(self):
|
|
896
|
-
"""
|
|
897
|
-
Test ReflectionInstance.getPublicStaticAsyncMethods() method functionality.
|
|
898
|
-
|
|
899
|
-
Verifies that the getPublicStaticAsyncMethods method correctly identifies and
|
|
900
|
-
returns only public static asynchronous methods from the wrapped instance,
|
|
901
|
-
excluding sync and non-public static methods.
|
|
902
|
-
|
|
903
|
-
Assertions
|
|
904
|
-
----------
|
|
905
|
-
- 'staticAsyncMethod' is included in the returned list
|
|
906
|
-
- 'staticMethod' is not included in the returned list
|
|
907
|
-
- 'static_async_method' is not included in the returned list
|
|
908
|
-
"""
|
|
909
|
-
reflect = ReflectionInstance(FakeClass())
|
|
910
|
-
public_static_async_methods = reflect.getPublicStaticAsyncMethods()
|
|
911
|
-
self.assertIn('staticAsyncMethod', public_static_async_methods)
|
|
912
|
-
self.assertNotIn('staticMethod', public_static_async_methods)
|
|
913
|
-
self.assertNotIn('static_async_method', public_static_async_methods)
|
|
914
|
-
|
|
915
|
-
async def testGetProtectedStaticMethods(self):
|
|
916
|
-
"""
|
|
917
|
-
Test ReflectionInstance.getProtectedStaticMethods() method functionality.
|
|
918
|
-
|
|
919
|
-
Verifies that the getProtectedStaticMethods method correctly identifies and
|
|
920
|
-
returns only protected static methods (prefixed with single underscore) from
|
|
921
|
-
the wrapped instance, excluding public and private static methods.
|
|
922
|
-
|
|
923
|
-
Assertions
|
|
924
|
-
----------
|
|
925
|
-
- '_staticMethodProtected' is included in the returned list
|
|
926
|
-
- 'staticMethod' is not included in the returned list
|
|
927
|
-
- '__staticMethodPrivate' is not included in the returned list
|
|
928
|
-
"""
|
|
929
|
-
reflect = ReflectionInstance(FakeClass())
|
|
930
|
-
protected_static_methods = reflect.getProtectedStaticMethods()
|
|
931
|
-
self.assertIn('_staticMethodProtected', protected_static_methods)
|
|
932
|
-
self.assertNotIn('staticMethod', protected_static_methods)
|
|
933
|
-
self.assertNotIn('__staticMethodPrivate', protected_static_methods)
|
|
934
|
-
|
|
935
|
-
async def testGetProtectedStaticSyncMethods(self):
|
|
936
|
-
"""
|
|
937
|
-
Test ReflectionInstance.getProtectedStaticSyncMethods() method functionality.
|
|
938
|
-
|
|
939
|
-
Verifies that the getProtectedStaticSyncMethods method correctly identifies and
|
|
940
|
-
returns only protected static synchronous methods (prefixed with single underscore)
|
|
941
|
-
from the wrapped instance, excluding async and non-protected static methods.
|
|
942
|
-
|
|
943
|
-
Assertions
|
|
944
|
-
----------
|
|
945
|
-
- '_staticMethodProtected' is included in the returned list
|
|
946
|
-
- 'staticAsyncMethod' is not included in the returned list
|
|
947
|
-
- '__staticMethodPrivate' is not included in the returned list
|
|
948
|
-
"""
|
|
949
|
-
reflect = ReflectionInstance(FakeClass())
|
|
950
|
-
protected_static_sync_methods = reflect.getProtectedStaticSyncMethods()
|
|
951
|
-
self.assertIn('_staticMethodProtected', protected_static_sync_methods)
|
|
952
|
-
self.assertNotIn('staticAsyncMethod', protected_static_sync_methods)
|
|
953
|
-
self.assertNotIn('__staticMethodPrivate', protected_static_sync_methods)
|
|
954
|
-
|
|
955
|
-
async def testGetProtectedStaticAsyncMethods(self):
|
|
956
|
-
"""
|
|
957
|
-
Test ReflectionInstance.getProtectedStaticAsyncMethods() method functionality.
|
|
958
|
-
|
|
959
|
-
Verifies that the getProtectedStaticAsyncMethods method correctly identifies and
|
|
960
|
-
returns only protected static asynchronous methods (prefixed with single underscore)
|
|
961
|
-
from the wrapped instance, excluding public and private static methods.
|
|
962
|
-
|
|
963
|
-
Assertions
|
|
964
|
-
----------
|
|
965
|
-
- '_staticAsyncMethodProtected' is included in the returned list
|
|
966
|
-
- 'staticMethod' is not included in the returned list
|
|
967
|
-
- '__staticMethodPrivate' is not included in the returned list
|
|
968
|
-
"""
|
|
969
|
-
reflect = ReflectionInstance(FakeClass())
|
|
970
|
-
protected_static_async_methods = reflect.getProtectedStaticAsyncMethods()
|
|
971
|
-
self.assertIn('_staticAsyncMethodProtected', protected_static_async_methods)
|
|
972
|
-
self.assertNotIn('staticMethod', protected_static_async_methods)
|
|
973
|
-
self.assertNotIn('__staticMethodPrivate', protected_static_async_methods)
|
|
974
|
-
|
|
975
|
-
async def testGetPrivateStaticMethods(self):
|
|
976
|
-
"""
|
|
977
|
-
Test ReflectionInstance.getPrivateStaticMethods() method functionality.
|
|
978
|
-
|
|
979
|
-
Verifies that the getPrivateStaticMethods method correctly identifies and
|
|
980
|
-
returns only private static methods (prefixed with double underscores) from
|
|
981
|
-
the wrapped instance, excluding protected and public static methods.
|
|
982
|
-
|
|
983
|
-
Assertions
|
|
984
|
-
----------
|
|
985
|
-
- '__staticMethodPrivate' is included in the returned list
|
|
986
|
-
- 'staticMethod' is not included in the returned list
|
|
987
|
-
- '_staticMethodProtected' is not included in the returned list
|
|
988
|
-
"""
|
|
989
|
-
reflect = ReflectionInstance(FakeClass())
|
|
990
|
-
private_static_methods = reflect.getPrivateStaticMethods()
|
|
991
|
-
self.assertIn('__staticMethodPrivate', private_static_methods)
|
|
992
|
-
self.assertNotIn('staticMethod', private_static_methods)
|
|
993
|
-
self.assertNotIn('_staticMethodProtected', private_static_methods)
|
|
994
|
-
|
|
995
|
-
async def testGetPrivateStaticSyncMethods(self):
|
|
996
|
-
"""
|
|
997
|
-
Test ReflectionInstance.getPrivateStaticSyncMethods() method functionality.
|
|
998
|
-
|
|
999
|
-
Verifies that the getPrivateStaticSyncMethods method correctly identifies and
|
|
1000
|
-
returns only private static synchronous methods (prefixed with double underscores)
|
|
1001
|
-
from the wrapped instance, excluding public and protected static methods.
|
|
1002
|
-
|
|
1003
|
-
Assertions
|
|
1004
|
-
----------
|
|
1005
|
-
- '__staticMethodPrivate' is included in the returned list
|
|
1006
|
-
- 'staticMethod' is not included in the returned list
|
|
1007
|
-
- '_staticMethodProtected' is not included in the returned list
|
|
1008
|
-
"""
|
|
1009
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1010
|
-
private_static_sync_methods = reflect.getPrivateStaticSyncMethods()
|
|
1011
|
-
self.assertIn('__staticMethodPrivate', private_static_sync_methods)
|
|
1012
|
-
self.assertNotIn('staticMethod', private_static_sync_methods)
|
|
1013
|
-
self.assertNotIn('_staticMethodProtected', private_static_sync_methods)
|
|
1014
|
-
|
|
1015
|
-
async def testGetPrivateStaticAsyncMethods(self):
|
|
1016
|
-
"""
|
|
1017
|
-
Test ReflectionInstance.getPrivateStaticAsyncMethods() method functionality.
|
|
1018
|
-
|
|
1019
|
-
Verifies that the getPrivateStaticAsyncMethods method correctly identifies and
|
|
1020
|
-
returns only private static asynchronous methods (prefixed with double underscores)
|
|
1021
|
-
from the wrapped instance, excluding public and protected static async methods.
|
|
1022
|
-
|
|
1023
|
-
Assertions
|
|
1024
|
-
----------
|
|
1025
|
-
- '__staticAsyncMethodPrivate' is included in the returned list
|
|
1026
|
-
- 'staticAsyncMethod' is not included in the returned list
|
|
1027
|
-
- '_staticAsyncMethodProtected' is not included in the returned list
|
|
1028
|
-
"""
|
|
1029
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1030
|
-
private_static_async_methods = reflect.getPrivateStaticAsyncMethods()
|
|
1031
|
-
self.assertIn('__staticAsyncMethodPrivate', private_static_async_methods)
|
|
1032
|
-
self.assertNotIn('staticAsyncMethod', private_static_async_methods)
|
|
1033
|
-
self.assertNotIn('_staticAsyncMethodProtected', private_static_async_methods)
|
|
1034
|
-
|
|
1035
|
-
async def testGetDunderMethods(self):
|
|
1036
|
-
"""
|
|
1037
|
-
Test ReflectionInstance.getDunderMethods() method functionality.
|
|
1038
|
-
|
|
1039
|
-
Verifies that the getDunderMethods method correctly identifies and returns
|
|
1040
|
-
dunder (double underscore) methods from the wrapped instance. Tests the
|
|
1041
|
-
detection of special Python methods with double underscore prefix and suffix.
|
|
1042
|
-
|
|
1043
|
-
Assertions
|
|
1044
|
-
----------
|
|
1045
|
-
- '__init__' is present in the returned list
|
|
1046
|
-
- '__class__' is present in the returned list
|
|
1047
|
-
"""
|
|
1048
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1049
|
-
dunder_methods = reflect.getDunderMethods()
|
|
1050
|
-
self.assertIn('__init__', dunder_methods)
|
|
1051
|
-
self.assertIn('__class__', dunder_methods)
|
|
1052
|
-
|
|
1053
|
-
async def testGetMagicMethods(self):
|
|
1054
|
-
"""
|
|
1055
|
-
Test ReflectionInstance.getMagicMethods() method functionality.
|
|
1056
|
-
|
|
1057
|
-
Verifies that the getMagicMethods method correctly identifies and returns
|
|
1058
|
-
magic methods (special Python methods with double underscores) from the
|
|
1059
|
-
wrapped instance. Tests the detection of commonly expected magic methods.
|
|
1060
|
-
|
|
1061
|
-
Assertions
|
|
1062
|
-
----------
|
|
1063
|
-
- '__init__' is present in the returned list
|
|
1064
|
-
- '__class__' is present in the returned list
|
|
1065
|
-
"""
|
|
1066
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1067
|
-
magic_methods = reflect.getMagicMethods()
|
|
1068
|
-
self.assertIn('__init__', magic_methods)
|
|
1069
|
-
self.assertIn('__class__', magic_methods)
|
|
1070
|
-
|
|
1071
|
-
async def testGetProperties(self):
|
|
1072
|
-
"""
|
|
1073
|
-
Test ReflectionInstance.getProperties() method functionality.
|
|
1074
|
-
|
|
1075
|
-
Verifies that the getProperties method correctly identifies and returns all
|
|
1076
|
-
properties (computed properties) from the wrapped instance, including public,
|
|
1077
|
-
protected, and private properties.
|
|
1078
|
-
|
|
1079
|
-
Assertions
|
|
1080
|
-
----------
|
|
1081
|
-
- 'computed_public_property' is present in the returned list
|
|
1082
|
-
- '_computed_property_protected' is present in the returned list
|
|
1083
|
-
- '__computed_property_private' is present in the returned list
|
|
1084
|
-
"""
|
|
1085
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1086
|
-
properties = reflect.getProperties()
|
|
1087
|
-
self.assertIn('computed_public_property', properties)
|
|
1088
|
-
self.assertIn('_computed_property_protected', properties)
|
|
1089
|
-
self.assertIn('__computed_property_private', properties)
|
|
1090
|
-
|
|
1091
|
-
async def testGetPublicProperties(self):
|
|
1092
|
-
"""
|
|
1093
|
-
Test ReflectionInstance.getPublicProperties() method functionality.
|
|
1094
|
-
|
|
1095
|
-
Verifies that the getPublicProperties method correctly identifies and returns
|
|
1096
|
-
only public properties from the wrapped instance, excluding protected and
|
|
1097
|
-
private properties based on Python naming conventions.
|
|
1098
|
-
|
|
1099
|
-
Assertions
|
|
1100
|
-
----------
|
|
1101
|
-
- 'computed_public_property' is included in the returned list
|
|
1102
|
-
- '_computed_property_protected' is not included in the returned list
|
|
1103
|
-
- '__computed_property_private' is not included in the returned list
|
|
1104
|
-
"""
|
|
1105
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1106
|
-
public_properties = reflect.getPublicProperties()
|
|
1107
|
-
self.assertIn('computed_public_property', public_properties)
|
|
1108
|
-
self.assertNotIn('_computed_property_protected', public_properties)
|
|
1109
|
-
self.assertNotIn('__computed_property_private', public_properties)
|
|
1110
|
-
|
|
1111
|
-
async def testGetProtectedProperties(self):
|
|
1112
|
-
"""
|
|
1113
|
-
Test ReflectionInstance.getProtectedProperties() method functionality.
|
|
1114
|
-
|
|
1115
|
-
Verifies that the getProtectedProperties method correctly identifies and returns
|
|
1116
|
-
only protected properties (prefixed with single underscore) from the wrapped
|
|
1117
|
-
instance, excluding public and private properties.
|
|
1118
|
-
|
|
1119
|
-
Assertions
|
|
1120
|
-
----------
|
|
1121
|
-
- '_computed_property_protected' is included in the returned list
|
|
1122
|
-
- 'computed_public_property' is not included in the returned list
|
|
1123
|
-
- '__computed_property_private' is not included in the returned list
|
|
1124
|
-
"""
|
|
1125
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1126
|
-
protected_properties = reflect.getProtectedProperties()
|
|
1127
|
-
self.assertIn('_computed_property_protected', protected_properties)
|
|
1128
|
-
self.assertNotIn('computed_public_property', protected_properties)
|
|
1129
|
-
self.assertNotIn('__computed_property_private', protected_properties)
|
|
1130
|
-
|
|
1131
|
-
async def testGetPrivateProperties(self):
|
|
1132
|
-
"""
|
|
1133
|
-
Test ReflectionInstance.getPrivateProperties() method functionality.
|
|
1134
|
-
|
|
1135
|
-
Verifies that the getPrivateProperties method correctly identifies and returns
|
|
1136
|
-
only private properties (prefixed with double underscores) from the wrapped
|
|
1137
|
-
instance, excluding public and protected properties.
|
|
1138
|
-
|
|
1139
|
-
Assertions
|
|
1140
|
-
----------
|
|
1141
|
-
- '__computed_property_private' is included in the returned list
|
|
1142
|
-
- 'computed_public_property' is not included in the returned list
|
|
1143
|
-
- '_computed_property_protected' is not included in the returned list
|
|
1144
|
-
"""
|
|
1145
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1146
|
-
private_properties = reflect.getPrivateProperties()
|
|
1147
|
-
self.assertIn('__computed_property_private', private_properties)
|
|
1148
|
-
self.assertNotIn('computed_public_property', private_properties)
|
|
1149
|
-
self.assertNotIn('_computed_property_protected', private_properties)
|
|
1150
|
-
|
|
1151
|
-
async def testGetProperty(self):
|
|
1152
|
-
"""
|
|
1153
|
-
Test ReflectionInstance.getProperty() method functionality.
|
|
1154
|
-
|
|
1155
|
-
Verifies that the getProperty method correctly retrieves the value of a
|
|
1156
|
-
computed property from the wrapped instance. Tests property value access
|
|
1157
|
-
through reflection and compares with direct property access.
|
|
1158
|
-
|
|
1159
|
-
Assertions
|
|
1160
|
-
----------
|
|
1161
|
-
- Property value retrieved through reflection equals direct property access value
|
|
1162
|
-
"""
|
|
1163
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1164
|
-
value = reflect.getProperty('computed_public_property')
|
|
1165
|
-
self.assertEqual(value, FakeClass().computed_public_property)
|
|
1166
|
-
|
|
1167
|
-
async def testGetPropertySignature(self):
|
|
1168
|
-
"""
|
|
1169
|
-
Test ReflectionInstance.getPropertySignature() method functionality.
|
|
1170
|
-
|
|
1171
|
-
Verifies that the getPropertySignature method correctly retrieves the
|
|
1172
|
-
signature of a specified property from the wrapped instance. Tests
|
|
1173
|
-
property signature inspection and string representation.
|
|
1174
|
-
|
|
1175
|
-
Assertions
|
|
1176
|
-
----------
|
|
1177
|
-
- Signature of 'computed_public_property' equals '(self) -> str'
|
|
1178
|
-
"""
|
|
1179
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1180
|
-
signature = reflect.getPropertySignature('computed_public_property')
|
|
1181
|
-
self.assertEqual(str(signature), '(self) -> str')
|
|
1182
|
-
|
|
1183
|
-
async def testGetPropertyDocstring(self):
|
|
1184
|
-
"""
|
|
1185
|
-
Test ReflectionInstance.getPropertyDocstring() method functionality.
|
|
1186
|
-
|
|
1187
|
-
Verifies that the getPropertyDocstring method correctly retrieves the
|
|
1188
|
-
docstring for a specified property from the wrapped instance. Tests
|
|
1189
|
-
property documentation extraction.
|
|
1190
|
-
|
|
1191
|
-
Assertions
|
|
1192
|
-
----------
|
|
1193
|
-
- Docstring for 'computed_public_property' contains 'Returns a string indicating this is a public'
|
|
1194
|
-
"""
|
|
1195
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1196
|
-
docstring = reflect.getPropertyDocstring('computed_public_property')
|
|
1197
|
-
self.assertIn('Returns a string indicating this is a public', docstring)
|
|
1198
|
-
|
|
1199
|
-
async def testGetConstructorDependencies(self):
|
|
1200
|
-
"""
|
|
1201
|
-
Test ReflectionInstance.getConstructorDependencies() method functionality.
|
|
1202
|
-
|
|
1203
|
-
Verifies that the getConstructorDependencies method returns an instance
|
|
1204
|
-
of ResolveArguments containing the constructor dependencies of the wrapped
|
|
1205
|
-
instance's class. Tests dependency analysis for class constructors.
|
|
1206
|
-
|
|
1207
|
-
Assertions
|
|
1208
|
-
----------
|
|
1209
|
-
- Returned value is an instance of ResolveArguments
|
|
1210
|
-
"""
|
|
1211
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1212
|
-
dependencies = reflect.getConstructorDependencies()
|
|
1213
|
-
self.assertIsInstance(dependencies, ResolveArguments)
|
|
1214
|
-
|
|
1215
|
-
async def testGetMethodDependencies(self):
|
|
1216
|
-
"""
|
|
1217
|
-
Test ReflectionInstance.getMethodDependencies() method functionality.
|
|
1218
|
-
|
|
1219
|
-
Verifies that the getMethodDependencies method correctly resolves the
|
|
1220
|
-
dependencies of a specified method from the wrapped instance. Tests
|
|
1221
|
-
method parameter type analysis and dependency resolution.
|
|
1222
|
-
|
|
1223
|
-
Assertions
|
|
1224
|
-
----------
|
|
1225
|
-
- 'x' parameter is present in resolved dependencies
|
|
1226
|
-
- 'y' parameter is present in resolved dependencies
|
|
1227
|
-
- Both parameters are identified as int type with correct metadata
|
|
1228
|
-
- No unresolved dependencies exist
|
|
1229
|
-
"""
|
|
1230
|
-
reflect = ReflectionInstance(FakeClass())
|
|
1231
|
-
method_deps: ResolveArguments = reflect.getMethodDependencies('instanceSyncMethod')
|
|
1232
|
-
self.assertIn('x', method_deps.unresolved)
|
|
1233
|
-
self.assertIn('y', method_deps.unresolved)
|