mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-01 16:37:56 +03:00 
			
		
		
		
	Implement DeclarativeCatalog.__repr__ and add some tests for it
This commit is contained in:
		
							parent
							
								
									3fc5f044f9
								
							
						
					
					
						commit
						4252fbfe4c
					
				|  | @ -243,7 +243,8 @@ class DeclarativeCatalogMetaClass(type): | |||
| 
 | ||||
|     def __repr__(cls): | ||||
|         """Return string representation of the catalog.""" | ||||
|         return '<DeclarativeCatalog {0}>'.format(cls.name) | ||||
|         return '<{0}({1})>'.format(cls.name, | ||||
|                                    ', '.join(six.iterkeys(cls.providers))) | ||||
| 
 | ||||
|     __str__ = __repr__ | ||||
| 
 | ||||
|  | @ -283,10 +284,10 @@ class DeclarativeCatalog(object): | |||
|     :param last_overriding: Reference to the last overriding catalog, if any | ||||
|     """ | ||||
| 
 | ||||
|     name = str() | ||||
|     catalog = DynamicCatalog | ||||
|     Bundle = CatalogBundle | ||||
| 
 | ||||
|     name = str() | ||||
| 
 | ||||
|     cls_providers = dict() | ||||
|     inherited_providers = dict() | ||||
|     providers = dict() | ||||
|  | @ -295,6 +296,8 @@ class DeclarativeCatalog(object): | |||
|     is_overridden = bool | ||||
|     last_overriding = None | ||||
| 
 | ||||
|     catalog = DynamicCatalog | ||||
| 
 | ||||
|     __IS_CATALOG__ = True | ||||
| 
 | ||||
|     @classmethod | ||||
|  |  | |||
|  | @ -248,6 +248,23 @@ class DeclarativeCatalogTests(unittest.TestCase): | |||
| 
 | ||||
|     def test_repr(self): | ||||
|         """Test declarative catalog representation.""" | ||||
|         self.assertIn('CatalogA', repr(CatalogA)) | ||||
|         self.assertIn('p11', repr(CatalogA)) | ||||
|         self.assertIn('p12', repr(CatalogA)) | ||||
| 
 | ||||
|         self.assertIn('CatalogB', repr(CatalogB)) | ||||
|         self.assertIn('p11', repr(CatalogB)) | ||||
|         self.assertIn('p12', repr(CatalogB)) | ||||
|         self.assertIn('p21', repr(CatalogB)) | ||||
|         self.assertIn('p22', repr(CatalogB)) | ||||
| 
 | ||||
|         self.assertIn('CatalogC', repr(CatalogC)) | ||||
|         self.assertIn('p11', repr(CatalogC)) | ||||
|         self.assertIn('p12', repr(CatalogC)) | ||||
|         self.assertIn('p21', repr(CatalogC)) | ||||
|         self.assertIn('p22', repr(CatalogC)) | ||||
|         self.assertIn('p31', repr(CatalogC)) | ||||
|         self.assertIn('p32', repr(CatalogC)) | ||||
| 
 | ||||
|     def test_abstract_catalog_backward_compatibility(self): | ||||
|         """Test that di.AbstractCatalog is available.""" | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user