mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-10-31 16:07:51 +03:00 
			
		
		
		
	Add more tests for factory
This commit is contained in:
		
							parent
							
								
									39e9059890
								
							
						
					
					
						commit
						ebd00b74e1
					
				|  | @ -6,9 +6,16 @@ class Animal: | |||
| 
 | ||||
| 
 | ||||
| class Cat(Animal): | ||||
|     ... | ||||
| 
 | ||||
|     @classmethod | ||||
|     def create(cls) -> Animal: | ||||
|         return cls() | ||||
| 
 | ||||
| 
 | ||||
| provider = providers.Factory(Cat) | ||||
| # Test 1: to check the return type (class) | ||||
| provider1 = providers.Factory(Cat) | ||||
| animal1: Animal = provider1(1, 2, 3, b='1', c=2, e=0.0) | ||||
| 
 | ||||
| animal: Animal = provider(1, 2, 3, b='1', c=2, e=0.0) | ||||
| # Test 2: to check the return type (class factory method) | ||||
| provider2 = providers.Factory(Cat.create) | ||||
| animal2: Animal = provider2() | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user