Python mock can be easily monkey patched. If you use it, you can unit test without a DI container. However, the body accustomed to DI containers wants IoC, so I decided to look for DI containers.
I want such a DI container.
Searching for DI Container on PyPi hits over 10,000. Eh, no way, all this?
152 hits when googled. Still too much!
Let's rely on our predecessors here.
This is the article that was introduced.
It becomes a constructor injection. It seems that it meets all the requirements, which may be good.
This is the article that was introduced.
It looks like a reimplementation of the above Injector. Is the dependency resolved by the argument name instead of the type hint?
Type hints will resolve the dependency. Whether it's a singleton or not is specified in code, not in the decorator. It's simple and may be necessary and sufficient.
It is a library that does not meet the requirements because it has to be registered in the container by itself or it needs to be set separately.
Recommended Posts