Skip to content

Commit

Permalink
fix module registry name preprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh committed Nov 27, 2023
1 parent 71db7bb commit ff5b3ff
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions autoregistry/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,11 @@ def __call__(

subregistry = RegistryDecorator(**config.asdict())
subregistry(handle)
self(subregistry, name=elem_name)
name = subregistry.__registry__.config.format(elem_name)
self(subregistry, name=name)
else:
self(handle, name=elem_name)
name = self.__registry__.config.format(elem_name)
self(handle, name=name)

return obj

Expand Down
1 change: 1 addition & 0 deletions tests/fake_module/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import fake_module_1, fake_submodule_1
from .fake_module_2 import __magic2__, _foo_private2, bar2, foo2
from .fake_module_3 import FakeModule3
2 changes: 2 additions & 0 deletions tests/fake_module/fake_module_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class FakeModule3:
pass
3 changes: 3 additions & 0 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def assert_fake_module_registry(registry, fake_module):
assert registry["fake_module_1"]["some_list"] == fake_module.fake_module_1.some_list
assert registry["fake_module_2"]["foo2"] == fake_module.fake_module_2.foo2
assert registry["fake_module_2"]["bar2"] == fake_module.fake_module_2.bar2
assert registry["fakemodule3"] == fake_module.FakeModule3
assert registry["foo2"] == fake_module.foo2


Expand All @@ -58,9 +59,11 @@ def test_defaults_module():
registry = Registry()
registry(fake_module)
assert list(registry) == [
"fakemodule3",
"bar2",
"fake_module_1",
"fake_module_2",
"fake_module_3",
"fake_submodule_1",
"foo2",
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_functions_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,4 @@ def test_module_non_recursive():

registry = Registry(recursive=False)
registry(fake_module)
assert list(registry) == ["bar2", "foo2"]
assert list(registry) == ["fakemodule3", "bar2", "foo2"]

0 comments on commit ff5b3ff

Please sign in to comment.