Skip to content

Commit

Permalink
Merge branch 'release/4.35.2' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
rmk135 committed Aug 6, 2021
2 parents b4ddf61 + 5acde87 commit cde7dee
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/main/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ that were made in every particular version.
From version 0.7.6 *Dependency Injector* framework strictly
follows `Semantic versioning`_

4.35.2
------
- Update wiring to support modules provided as packages.
See issue `#481 <https://github.com/ets-labs/python-dependency-injector/issues/481>`_.
Thanks to `@Sadbot <https://github.com/Sadbot>`_ for demonstrating the issue.

4.35.1
------
- Fix a container issue with supporting custom string types.
Expand Down
2 changes: 1 addition & 1 deletion src/dependency_injector/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Top-level package."""

__version__ = '4.35.1'
__version__ = '4.35.2'
"""Version number.
:type: str
Expand Down
2 changes: 2 additions & 0 deletions src/dependency_injector/wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,8 @@ def _unbind_injections(fn: Callable[..., Any]) -> None:

def _fetch_modules(package):
modules = [package]
if not hasattr(package, '__path__') or not hasattr(package, '__name__'):
return modules
for module_info in pkgutil.walk_packages(
path=package.__path__,
prefix=package.__name__ + '.',
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/wiring/test_wiring_py36.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,18 @@ def test_container(self):
self.assertIsInstance(service, Service)


class ModuleAsPackagingTest(unittest.TestCase):

def setUp(self):
self.container = Container(config={'a': {'b': {'c': 10}}})
self.addCleanup(self.container.unwire)

def test_module_as_package_wiring(self):
# See: https://github.com/ets-labs/python-dependency-injector/issues/481
self.container.wire(packages=[module])
self.assertIsInstance(module.service, Service)


class WiringAndQueue(unittest.TestCase):

def test_wire_queue(self) -> None:
Expand Down

0 comments on commit cde7dee

Please sign in to comment.