From ebd00b74e18c94e7b9e88e34195bfe432a3cc583 Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Mon, 24 Aug 2020 17:12:49 -0400 Subject: [PATCH] Add more tests for factory --- tests/typing/factory.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/typing/factory.py b/tests/typing/factory.py index a13c79e7..0fe294e0 100644 --- a/tests/typing/factory.py +++ b/tests/typing/factory.py @@ -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()