Add support of positional context argument injections

This commit is contained in:
Roman Mogylatov 2020-06-14 17:27:06 -04:00
parent f1cc113e33
commit 671bb42bbb
4 changed files with 352 additions and 348 deletions

View File

@ -18,6 +18,7 @@ positional argument injections the same way as :py:class:`Factory` provider:
+ Providers could be injected "as is" (delegated), if it is defined explicitly. Check out
:ref:`factory_providers_delegation`.
+ All other values are injected *"as is"*.
+ Positional context arguments will be appended after :py:class:`List` positional injections.
Full example:
@ -28,7 +29,6 @@ Full example:
.. note::
Positional context argument injections and keyword argument injections are not
supported.
Keyword argument injections are not supported.
.. disqus::

File diff suppressed because it is too large Load Diff

View File

@ -1972,8 +1972,7 @@ cdef class List(Provider):
:py:class:`List` provider is needed for injecting a list of dependencies. It handles
positional argument injections the same way as :py:class:`Factory` provider.
Positional context argument injections and keyword argument injections are not
supported.
Keyword argument injections are not supported.
.. code-block:: python

View File

@ -23,6 +23,11 @@ class ListTests(unittest.TestCase):
self.assertIsNot(list1, list2)
def test_call_with_context_args(self):
provider = providers.List('i1', 'i2')
self.assertEqual(provider('i3', 'i4'), ['i1', 'i2', 'i3', 'i4'])
def test_fluent_interface(self):
provider = providers.List() \
.add_args(1, 2)