Merge remote-tracking branch 'origin/callable_injections_attribute'

This commit is contained in:
Roman Mogilatov 2015-10-22 17:48:34 +03:00
commit 0da60aafef
3 changed files with 15 additions and 1 deletions

View File

@ -264,6 +264,11 @@ class Callable(Provider):
return self.callback(*_get_injectable_args(args, self.args),
**_get_injectable_kwargs(kwargs, self.kwargs))
@property
def injections(self):
"""Return tuple of all injections."""
return self.args + self.kwargs
class Config(Provider):
"""Config provider.

View File

@ -17,9 +17,13 @@ Development version
examples.
- Add functionality for using positional argument injections with
``di.Factory``, ``di.Singleton`` and ``di.Callable`` providers.
- Add functionality for decorating classes with ``@di.inject``.
- Add ``di.Singleton.injections`` attribute that represents a tuple of all
``di.Singleton`` injections (including args, kwargs, attributes and methods).
- Add ``di.Callable.injections`` attribute that represents a tuple of all
``di.Callable`` injections (including args and kwargs).
- Add optimization for ``di.Injection.value`` property that will compute
type of injection once, instead of doing this on every call.
- Add functionality for decorating classes with ``@di.inject``.
- Add support of Python 3.5.
- Add support of six 1.10.0.
- Add minor refactorings and code style fixes.

View File

@ -755,6 +755,11 @@ class CallableTests(unittest.TestCase):
self.assertTupleEqual(provider(), (1, 2, 3, 4))
def test_injections(self):
"""Test getting a full list of injections using injections property."""
provider = di.Factory(self.example, 1, 2, arg3=3, arg4=4)
self.assertEquals(len(provider.injections), 4)
class ConfigTests(unittest.TestCase):
"""Config test cases."""