diff --git a/dependency_injector/injections.py b/dependency_injector/injections.py index b5c1e0b5..149d91d8 100644 --- a/dependency_injector/injections.py +++ b/dependency_injector/injections.py @@ -77,11 +77,12 @@ def inject(*args, **kwargs): def decorated(*args, **kwargs): """Decorated with dependency injection callback.""" if decorated.args: - args = tuple(arg.inject() for arg in decorated.args) + args + args = tuple(arg.provide_injection() + for arg in decorated.args) + args for name, arg in six.iteritems(decorated.kwargs): if name not in kwargs: - kwargs[name] = arg.inject() + kwargs[name] = arg.provide_injection() return callback(*args, **kwargs) diff --git a/dependency_injector/providers/base.py b/dependency_injector/providers/base.py index 4b740497..193af545 100644 --- a/dependency_injector/providers/base.py +++ b/dependency_injector/providers/base.py @@ -83,7 +83,7 @@ class Provider(object): """Call last overriding provider and return result.""" return self.last_overriding(*args, **kwargs) - def inject(self): + def provide_injection(self): """Injection strategy implementation. :rtype: object diff --git a/dependency_injector/providers/callable.py b/dependency_injector/providers/callable.py index 578d5e0d..62be51df 100644 --- a/dependency_injector/providers/callable.py +++ b/dependency_injector/providers/callable.py @@ -97,11 +97,11 @@ class Callable(Provider): :rtype: object """ if self.args: - args = tuple(arg.inject() for arg in self.args) + args + args = tuple(arg.provide_injection() for arg in self.args) + args for name, arg in six.iteritems(self.kwargs): if name not in kwargs: - kwargs[name] = arg.inject() + kwargs[name] = arg.provide_injection() return self.provides(*args, **kwargs) @@ -122,7 +122,7 @@ class DelegatedCallable(Callable): "as is". """ - def inject(self): + def provide_injection(self): """Injection strategy implementation. :rtype: object diff --git a/dependency_injector/providers/creational.py b/dependency_injector/providers/creational.py index 712f40ce..40c72133 100644 --- a/dependency_injector/providers/creational.py +++ b/dependency_injector/providers/creational.py @@ -113,7 +113,7 @@ class Factory(Callable): instance = super(Factory, self)._provide(*args, **kwargs) for name, arg in six.iteritems(self.attributes): - setattr(instance, name, arg.inject()) + setattr(instance, name, arg.provide_injection()) return instance @@ -140,7 +140,7 @@ class DelegatedFactory(Factory): :type: type """ - def inject(self): + def provide_injection(self): """Injection strategy implementation. :rtype: object @@ -243,7 +243,7 @@ class DelegatedSingleton(Singleton): :type: type """ - def inject(self): + def provide_injection(self): """Injection strategy implementation. :rtype: object diff --git a/tests/providers/test_callable.py b/tests/providers/test_callable.py index f6a8f3da..4b78ff4b 100644 --- a/tests/providers/test_callable.py +++ b/tests/providers/test_callable.py @@ -111,4 +111,4 @@ class DelegatedCallableTests(unittest.TestCase): def test_is_delegated_provider(self): """Test is_delegated_provider.""" provider = providers.DelegatedCallable(len) - self.assertIs(provider.inject(), provider) + self.assertIs(provider.provide_injection(), provider) diff --git a/tests/providers/test_creational.py b/tests/providers/test_creational.py index 10feae63..900a17a6 100644 --- a/tests/providers/test_creational.py +++ b/tests/providers/test_creational.py @@ -242,7 +242,7 @@ class DelegatedFactoryTests(unittest.TestCase): def test_is_delegated_provider(self): """Test is_delegated_provider.""" provider = providers.DelegatedFactory(object) - self.assertIs(provider.inject(), provider) + self.assertIs(provider.provide_injection(), provider) class SingletonTests(unittest.TestCase): @@ -481,7 +481,7 @@ class DelegatedSingletonTests(unittest.TestCase): def test_is_delegated_provider(self): """Test is_delegated_provider.""" provider = providers.DelegatedSingleton(object) - self.assertIs(provider.inject(), provider) + self.assertIs(provider.provide_injection(), provider) class FactoryAsDecoratorTests(unittest.TestCase):