mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 01:26:51 +03:00
Add Callable.injections read-only attribute for getting a full list of Callable injections
This commit is contained in:
parent
2052992a99
commit
5bdca32779
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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."""
|
||||
|
|
Loading…
Reference in New Issue
Block a user