mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-02-07 07:00:49 +03:00
Add a note on individuals import to wiring docs
This commit is contained in:
parent
6e53a7c0c6
commit
4c039d012e
|
@ -153,6 +153,23 @@ You can use that in testing to re-create and re-wire a container before each tes
|
|||
Wiring can take time if you have a large codebase. Consider to persist a container instance and
|
||||
avoid re-wiring between tests.
|
||||
|
||||
.. note::
|
||||
Python has a limitation on patching already imported individual members. To protect from errors
|
||||
prefer an import of modules instead of individual members or make sure that imports happen
|
||||
after the wiring:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from . import module
|
||||
|
||||
module.fn()
|
||||
|
||||
# instead of
|
||||
|
||||
from .module import fn
|
||||
|
||||
fn()
|
||||
|
||||
Integration with other frameworks
|
||||
---------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user