mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-10-31 16:07:51 +03:00 
			
		
		
		
	Fix bug with injections of catalog bundles
This commit is contained in:
		
							parent
							
								
									682c4498ca
								
							
						
					
					
						commit
						53025756d8
					
				|  | @ -51,6 +51,8 @@ class CatalogBundle(object): | ||||||
| 
 | 
 | ||||||
|     def __getattr__(self, item): |     def __getattr__(self, item): | ||||||
|         """Raise an error on every attempt to get undefined provider.""" |         """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) |         self._raise_undefined_provider_error(item) | ||||||
| 
 | 
 | ||||||
|     def __repr__(self): |     def __repr__(self): | ||||||
|  |  | ||||||
|  | @ -23,6 +23,17 @@ class InjectionTests(unittest.TestCase): | ||||||
|         injection = di.Injection('some_arg_name', di.Factory(object)) |         injection = di.Injection('some_arg_name', di.Factory(object)) | ||||||
|         self.assertIsInstance(injection.value, 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): | class KwArgTests(unittest.TestCase): | ||||||
|     """Keyword arg injection test cases.""" |     """Keyword arg injection test cases.""" | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user