mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 09:36:48 +03:00
Merge remote-tracking branch 'origin/callable_injections_attribute'
This commit is contained in:
commit
0da60aafef
|
@ -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