diff --git a/dependency_injector/catalog.py b/dependency_injector/catalog.py index eb674756..61f1663c 100644 --- a/dependency_injector/catalog.py +++ b/dependency_injector/catalog.py @@ -51,6 +51,8 @@ class CatalogBundle(object): def __getattr__(self, item): """Raise an error on every attempt to get undefined provider.""" + if item.startswith('__') and item.endswith('__'): + return super(CatalogBundle, self).__getattr__(item) self._raise_undefined_provider_error(item) def __repr__(self): diff --git a/tests/test_injections.py b/tests/test_injections.py index f84ad280..c96567b7 100644 --- a/tests/test_injections.py +++ b/tests/test_injections.py @@ -23,6 +23,17 @@ class InjectionTests(unittest.TestCase): injection = di.Injection('some_arg_name', di.Factory(object)) self.assertIsInstance(injection.value, object) + def test_value_with_catalog_bundle_injectable(self): + """Test Injection value property with catalog bundle.""" + class TestCatalog(di.AbstractCatalog): + """Test catalog.""" + + provider = di.Provider() + injection = di.Injection('some_arg_name', + TestCatalog.Bundle(TestCatalog.provider)) + + self.assertIsInstance(injection.value, TestCatalog.Bundle) + class KwArgTests(unittest.TestCase): """Keyword arg injection test cases."""