diff --git a/tests/test_providers.py b/tests/test_providers.py index 82761606..93fabcae 100644 --- a/tests/test_providers.py +++ b/tests/test_providers.py @@ -1089,3 +1089,27 @@ class ConfigTests(unittest.TestCase): 'ChildConfig({0}) at {1}>'.format( repr('.'.join(('category', 'setting'))), hex(id(category_setting)))) + + +class FactoryAsDecoratorTests(unittest.TestCase): + """Factory as decorator tests.""" + + def test_decoration(self): + """Test decoration of some class with Factory provider.""" + @providers.Factory + class AuthService(object): + """Auth service.""" + + @providers.Factory + @injections.inject(auth_service=AuthService) + class UsersService(object): + """Users service.""" + + def __init__(self, auth_service): + """Initializer.""" + self.auth_service = auth_service + + users_service = UsersService() + + self.assertIsInstance(users_service, UsersService.cls) + self.assertIsInstance(users_service.auth_service, AuthService.cls)