1111from monic .expressions import (
1212 ExpressionsParser ,
1313 ExpressionsInterpreter ,
14- register ,
15- register_module ,
14+ monic_bind ,
15+ monic_bind_module ,
1616)
1717from monic .expressions .registry import registry , NamespaceProxy
1818
@@ -27,12 +27,12 @@ def reset_registry():
2727def test_registered_function ():
2828 """Test using registered functions."""
2929
30- @register
30+ @monic_bind
3131 def custom_add (x , y ): # pylint: disable=unused-variable
3232 """Custom addition function."""
3333 return x + y
3434
35- @register ("multiply" )
35+ @monic_bind ("multiply" )
3636 def custom_multiply (x , y ): # pylint: disable=unused-variable
3737 """Custom multiplication function."""
3838 return x * y
@@ -52,7 +52,7 @@ def custom_multiply(x, y): # pylint: disable=unused-variable
5252def test_registered_class ():
5353 """Test using registered class."""
5454
55- @register
55+ @monic_bind
5656 class Point : # pylint: disable=unused-variable
5757 """A simple 2D point class."""
5858
@@ -77,7 +77,7 @@ def distance_from_origin(self):
7777def test_register_without_name ():
7878 """Test registering an object without explicit name."""
7979
80- @register
80+ @monic_bind
8181 def test_func (): # pylint: disable=unused-variable
8282 return 42
8383
@@ -92,7 +92,7 @@ def test_func(): # pylint: disable=unused-variable
9292def test_register_with_name ():
9393 """Test registering an object with explicit name."""
9494
95- @register ("answer" )
95+ @monic_bind ("answer" )
9696 def get_answer (): # pylint: disable=unused-variable
9797 return 42
9898
@@ -107,15 +107,15 @@ def get_answer(): # pylint: disable=unused-variable
107107def test_register_with_nested_name ():
108108 """Test registering objects with nested names."""
109109
110- @register ("math.functions.add" )
110+ @monic_bind ("math.functions.add" )
111111 def add (x , y ): # pylint: disable=unused-variable
112112 return x + y
113113
114- @register ("math.functions.multiply" )
114+ @monic_bind ("math.functions.multiply" )
115115 def multiply (x , y ): # pylint: disable=unused-variable
116116 return x * y
117117
118- @register ("math.constants" )
118+ @monic_bind ("math.constants" )
119119 class MathConstants : # pylint: disable=unused-variable
120120 PI = 3.14159
121121 E = 2.71828
@@ -139,14 +139,14 @@ class MathConstants: # pylint: disable=unused-variable
139139def test_register_nested_name_conflict ():
140140 """Test that registering conflicting nested names raises an error."""
141141
142- @register ("math.functions.add" )
142+ @monic_bind ("math.functions.add" )
143143 def add1 (x , y ): # pylint: disable=unused-variable
144144 return x + y # pragma: no cover
145145
146146 # Try to register another function with the same nested name
147147 with pytest .raises (ValueError ) as exc_info :
148148
149- @register ("math.functions.add" )
149+ @monic_bind ("math.functions.add" )
150150 def add2 (x , y ): # pylint: disable=unused-variable
151151 return x + y # pragma: no cover
152152
@@ -156,14 +156,14 @@ def add2(x, y): # pylint: disable=unused-variable
156156def test_register_nested_name_non_namespace_conflict ():
157157 """Test conflict between nested name and non-namespace object."""
158158
159- @register ("math" )
159+ @monic_bind ("math" )
160160 def math_func (): # pylint: disable=unused-variable
161161 return 42 # pragma: no cover
162162
163163 # Try to register a function in math.functions namespace
164164 with pytest .raises (ValueError ) as exc_info :
165165
166- @register ("math.functions.add" )
166+ @monic_bind ("math.functions.add" )
167167 def add (x , y ): # pylint: disable=unused-variable
168168 return x + y # pragma: no cover
169169
@@ -173,11 +173,11 @@ def add(x, y): # pylint: disable=unused-variable
173173def test_register_both_syntaxes ():
174174 """Test both decorator syntaxes work correctly."""
175175
176- @register
176+ @monic_bind
177177 def func1 (): # pylint: disable=unused-variable
178178 return 1
179179
180- @register ()
180+ @monic_bind ()
181181 def func2 (): # pylint: disable=unused-variable
182182 return 2
183183
@@ -196,11 +196,11 @@ def func2(): # pylint: disable=unused-variable
196196def test_register_class_both_syntaxes ():
197197 """Test both decorator syntaxes work correctly with classes."""
198198
199- @register
199+ @monic_bind
200200 class Class1 : # pylint: disable=unused-variable
201201 value = 1
202202
203- @register ()
203+ @monic_bind ()
204204 class Class2 : # pylint: disable=unused-variable
205205 value = 2
206206
@@ -218,10 +218,10 @@ class Class2: # pylint: disable=unused-variable
218218 assert interpreter .get_name_value ("result2" ) == 2
219219
220220
221- def test_register_module ():
221+ def test_bind_module ():
222222 """Test registering and using a module."""
223- # Register math module
224- register_module ("math" )
223+ # Bind math module
224+ monic_bind_module ("math" )
225225
226226 code = """
227227 result1 = math.sqrt(16)
@@ -237,10 +237,10 @@ def test_register_module():
237237 )
238238
239239
240- def test_register_module_with_alias ():
240+ def test_bind_module_with_alias ():
241241 """Test registering a module with an alias."""
242- # Register random module with alias
243- register_module ("random" , alias = "rand" )
242+ # Bind random module with alias
243+ monic_bind_module ("random" , alias = "rand" )
244244
245245 code = """
246246 rand.seed(42) # For reproducibility
@@ -255,10 +255,10 @@ def test_register_module_with_alias():
255255 assert 1 <= result <= 10
256256
257257
258- def test_register_module_submodule ():
258+ def test_bind_module_submodule ():
259259 """Test registering a module with submodules."""
260- # Register collections.abc module
261- register_module ("collections.abc" , alias = "collabc" )
260+ # Bind collections.abc module
261+ monic_bind_module ("collections.abc" , alias = "collabc" )
262262
263263 code = """
264264 is_sequence = collabc.Sequence
@@ -272,11 +272,11 @@ def test_register_module_submodule():
272272 assert result is True
273273
274274
275- def test_register_module_with_nested_name ():
275+ def test_bind_module_with_nested_name ():
276276 """Test registering modules with nested names."""
277- # Register urllib and its parse submodule
278- register_module ("urllib" , alias = "url" )
279- register_module ("urllib.parse" , alias = "url.parse" )
277+ # Bind urllib and its parse submodule
278+ monic_bind_module ("urllib" , alias = "url" )
279+ monic_bind_module ("urllib.parse" , alias = "url.parse" )
280280
281281 code = """
282282 # Use urllib.parse module
@@ -336,34 +336,34 @@ def test_register_object_without_name():
336336 )
337337
338338
339- def test_register_module_import_error ():
339+ def test_bind_module_import_error ():
340340 """Test that registering a non-existent module raises ImportError."""
341341 with pytest .raises (ImportError ) as exc_info :
342- register_module ("non_existent_module" )
342+ monic_bind_module ("non_existent_module" )
343343
344344 assert "Failed to import module 'non_existent_module'" in str (
345345 exc_info .value
346346 )
347347
348348
349- def test_register_module_duplicate ():
349+ def test_bind_module_duplicate ():
350350 """Test that registering the same module twice raises ValueError."""
351- register_module ("math" )
351+ monic_bind_module ("math" )
352352
353353 with pytest .raises (ValueError ) as exc_info :
354- register_module ("math" )
354+ monic_bind_module ("math" )
355355
356356 assert "Module 'math' is already registered" in str (exc_info .value )
357357
358358
359359def test_get_all_with_nested_namespaces ():
360360 """Test that get_all properly handles nested namespaces."""
361361
362- @register ("math.functions.add" )
362+ @monic_bind ("math.functions.add" )
363363 def add (x , y ): # pylint: disable=unused-variable
364364 return x + y # pragma: no cover
365365
366- @register ("math.constants" )
366+ @monic_bind ("math.constants" )
367367 class Constants : # pylint: disable=unused-variable
368368 PI = 3.14159
369369
@@ -411,8 +411,8 @@ def test_func():
411411
412412def test_get_all_with_modules ():
413413 """Test that get_all properly includes registered modules."""
414- register_module ("math" , alias = "math_alias" )
415- register_module ("random" )
414+ monic_bind_module ("math" , alias = "math_alias" )
415+ monic_bind_module ("random" )
416416
417417 all_objects = registry .get_all ()
418418 assert "math_alias" in all_objects
@@ -475,16 +475,16 @@ def test_get_all_with_mixed_content():
475475 Test that get_all properly handles mixed content
476476 (modules, objects, namespaces).
477477 """
478- # Register a module
479- register_module ("math" )
478+ # Bind a module
479+ monic_bind_module ("math" )
480480
481- # Register a function in a namespace
482- @register ("utils.helper" )
481+ # Bind a function in a namespace
482+ @monic_bind ("utils.helper" )
483483 def helper (): # pylint: disable=unused-variable
484484 pass # pragma: no cover
485485
486- # Register a direct object
487- @register
486+ # Bind a direct object
487+ @monic_bind
488488 def direct_func (): # pylint: disable=unused-variable
489489 pass # pragma: no cover
490490
@@ -498,7 +498,7 @@ def direct_func(): # pylint: disable=unused-variable
498498def test_is_registered_with_string_name ():
499499 """Test is_registered with a string name."""
500500
501- @register ("test.func" )
501+ @monic_bind ("test.func" )
502502 def test_func (): # pylint: disable=unused-variable
503503 pass # pragma: no cover
504504
@@ -509,15 +509,15 @@ def test_func(): # pylint: disable=unused-variable
509509def test_get_all_with_non_dict_values ():
510510 """Test that get_all properly handles non-dict values."""
511511
512- @register ("test.value" )
512+ @monic_bind ("test.value" )
513513 def test_func (): # pylint: disable=unused-variable
514514 pass # pragma: no cover
515515
516- @register ("direct_value" )
516+ @monic_bind ("direct_value" )
517517 def direct_func (): # pylint: disable=unused-variable
518518 pass # pragma: no cover
519519
520- register_module ("math" )
520+ monic_bind_module ("math" )
521521
522522 all_objects = registry .get_all ()
523523 assert callable (all_objects ["test" ].value ) # Nested function
0 commit comments