mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-26 03:23:58 +03:00
18 lines
405 B
Python
18 lines
405 B
Python
|
"""Declarative container provider override example."""
|
||
|
|
||
|
import sqlite3
|
||
|
from unittest import mock
|
||
|
|
||
|
from dependency_injector import containers, providers
|
||
|
|
||
|
|
||
|
class Container(containers.DeclarativeContainer):
|
||
|
|
||
|
database = providers.Singleton(sqlite3.connect, ':memory:')
|
||
|
|
||
|
|
||
|
container = Container(database=mock.Mock(sqlite3.Connection))
|
||
|
|
||
|
database = container.database()
|
||
|
assert isinstance(database, mock.Mock)
|