Fix bug with injections of catalog bundles

This commit is contained in:
Roman Mogilatov 2015-10-19 10:47:24 +03:00
parent 682c4498ca
commit 53025756d8
2 changed files with 13 additions and 0 deletions

View File

@ -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):

View File

@ -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."""