Add providers overriding to demo 2

This commit is contained in:
Roman Mogylatov 2020-08-14 15:31:33 -04:00
parent 88866d596b
commit 684745a6b4

View File

@ -1,4 +1,5 @@
from dependency_injector import containers, providers
from unittest import mock
class ApiClient:
@ -35,5 +36,9 @@ if __name__ == '__main__':
container.config.from_yaml('config.yml')
service = container.service()
assert isinstance(service.api_client, ApiClient)
with container.api_client.override(mock.Mock()):
service = container.service()
assert isinstance(service.api_client, mock.Mock)