Add more tests for factory

This commit is contained in:
Roman Mogylatov 2020-08-24 17:12:49 -04:00
parent 39e9059890
commit ebd00b74e1

View File

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