Example #1
0
def test_relative_names_with_auto_package():
    service = module.test_function()
    assert isinstance(service, Service)

    from samples.wiring.package.subpackage.submodule import test_function
    service = test_function()
    assert isinstance(service, Service)
Example #2
0
def test_absolute_names():
    service = module.test_function()
    assert isinstance(service, Service)

    from samples.wiring.package.subpackage.submodule import test_function
    service = test_function()
    assert isinstance(service, Service)
def test_relative_names_with_auto_package(container: Container):
    wire_with_relative_string_names(container)

    service = module.test_function()
    assert isinstance(service, Service)

    from samples.wiring.package.subpackage.submodule import test_function
    service = test_function()
    assert isinstance(service, Service)
def test_absolute_names(container: Container):
    container.wire(
        modules=["samples.wiring.module"],
        packages=["samples.wiring.package"],
    )

    service = module.test_function()
    assert isinstance(service, Service)

    from samples.wiring.package.subpackage.submodule import test_function
    service = test_function()
    assert isinstance(service, Service)
def test_relative_names_with_explicit_package(container: Container):
    container.wire(
        modules=[".module"],
        packages=[".package"],
        from_package="samples.wiring",
    )

    service = module.test_function()
    assert isinstance(service, Service)

    from samples.wiring.package.subpackage.submodule import test_function
    service = test_function()
    assert isinstance(service, Service)
def test_package_submodule_lookup():
    from samples.wiring.package.subpackage.submodule import test_function
    service = test_function()
    assert isinstance(service, Service)
def test_unwire_package_function_by_reference(container: Container):
    from samples.wiring.package.subpackage import submodule
    container.unwire()
    assert isinstance(submodule.test_function(), Provide)
def test_unwire_package_function(container: Container):
    container.unwire()
    from samples.wiring.package.subpackage.submodule import test_function
    assert isinstance(test_function(), Provide)