From 53025756d87b5f4121b5fa78b0dbb1b648eee77d Mon Sep 17 00:00:00 2001 From: Roman Mogilatov Date: Mon, 19 Oct 2015 10:47:24 +0300 Subject: [PATCH] Fix bug with injections of catalog bundles --- dependency_injector/catalog.py | 2 ++ tests/test_injections.py | 11 +++++++++++ 2 files changed, 13 insertions(+) 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."""