Exemplo n.º 1
0
def _create_elements(*factories) -> Sequence[Element]:
    return [
        Element(
            injector=FactoryInjector(c),
            strategy=_default_strategy,
        ) for c in factories
    ]
Exemplo n.º 2
0
def _functional_test_factory_injector(provider: FactoryInjector):
    dependencies = list(provider.dependencies())
    assert len(dependencies) == 2
    assert dependencies[0].arg == "x"
    assert dependencies[0].type == X
    assert dependencies[0].mandatory
    assert dependencies[1].arg == "extra"
    assert dependencies[1].type == str
    assert not dependencies[1].mandatory
Exemplo n.º 3
0
 def __iter__(self) -> Iterator[ModuleElement]:
     for factory in self.factories:
         yield ModuleElement.create(
             injector=FactoryInjector(factory),
             singleton=self.singleton,
             label=_factory_name(factory),
             export=self.export,
             bootstrap=self.bootstrap,
             agg_checks=self.agg_checks,
         )
Exemplo n.º 4
0
 def __iter__(self) -> Iterator[ModuleElement]:
     for python_module in self.python_modules:
         for filters in self.filter_sets:
             inspector = ModuleFactoriesInspector(filters=filters)
             for name, factory in inspector.filtered_factories(
                     python_module):
                 yield ModuleElement.create(
                     injector=FactoryInjector(factory),
                     singleton=self.singleton,
                     label=_factory_name(factory),
                     export=self.export,
                     bootstrap=self.bootstrap,
                     agg_checks=self.agg_checks,
                 )
Exemplo n.º 5
0
def test_fn_str_factory_injector():
    injector = FactoryInjector(y_str)
    _functional_test_factory_injector(injector)
Exemplo n.º 6
0
def test_type_factory_injector():
    injector = FactoryInjector(Y)

    _functional_test_factory_injector(injector)