mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 09:36:48 +03:00
2e940adb50
* Add basic setup * Add more tests for factory * Add mypy checks to CI * Add mypy checks to makefile command * Add typing for the factories * Add stub for Callable providers * Add typing module and object provider stubs * Fix typing test issue * Remove typing module * Add Delegate stub * Add stub for Dependency provider * Add stub for ExternalDependency * Add stubs for providers module functions * Add stubs for the DependenciesContainer provider * Add stub for the CallableDelegate provider * Add stubs for Coroutine providers * Add stubs for the configuration options * Add stub for the FactoryDelegate * Add stub for the FactoryAggregate provider * Add singleton stubs * Add stubs for singletons * Add stub for the List provider * Add stub for the Container provider * Add stub for the Selector provider * Add stubs for the dynamic container * Add stub for the declarative container * Add stubs for the extensions * Add types module for explicit provider typing * Set absolute import mode for the providers module and add types module test * Skip typing test for Python 3.5 * Remove coroutine test from py35 * Fix py35 tests * Add \n to the tox.ini
30 lines
851 B
Python
30 lines
851 B
Python
from dependency_injector import providers
|
|
|
|
|
|
# Test 1: to check the return type
|
|
provider1 = providers.Selector(
|
|
lambda: 'a',
|
|
a=providers.Factory(object),
|
|
b=providers.Factory(object),
|
|
)
|
|
var1: int = provider1()
|
|
|
|
# Test 2: to check the provided instance interface
|
|
provider2 = providers.Selector(
|
|
lambda: 'a',
|
|
a=providers.Factory(object),
|
|
b=providers.Factory(object),
|
|
)
|
|
provided2: providers.ProvidedInstance = provider2.provided
|
|
attr_getter2: providers.AttributeGetter = provider2.provided.attr
|
|
item_getter2: providers.ItemGetter = provider2.provided['item']
|
|
method_caller2: providers.MethodCaller = provider2.provided.method.call(123, arg=324)
|
|
|
|
# Test3 to check the getattr
|
|
provider3 = providers.Selector(
|
|
lambda: 'a',
|
|
a=providers.Factory(object),
|
|
b=providers.Factory(object),
|
|
)
|
|
attr3: providers.Provider = provider3.a
|