python-dependency-injector/tests/unit/wiring/provider_ids/test_autoloader_py36.py
Roman Mogylatov f0c55cda22 Fix a typo
2022-03-27 14:23:35 -04:00

42 lines
1.0 KiB
Python

"""Autoloader tests."""
import contextlib
import importlib
from dependency_injector.wiring import register_loader_containers, unregister_loader_containers
from pytest import fixture
from samples.wiring import module
from samples.wiring.service import Service
from samples.wiring.container import Container
@fixture
def container():
container = Container()
yield container
with contextlib.suppress(ValueError):
unregister_loader_containers(container)
container.unwire()
importlib.reload(module)
def test_register_container(container: Container) -> None:
register_loader_containers(container)
importlib.reload(module)
service = module.test_function()
assert isinstance(service, Service)
def test_numpy_scipy_and_builtins_dont_break_wiring(container: Container) -> None:
register_loader_containers(container)
importlib.reload(module)
importlib.import_module("samples.wiring.imports")
service = module.test_function()
assert isinstance(service, Service)