mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-28 04:23:59 +03:00
19 lines
500 B
Python
19 lines
500 B
Python
"""Dynamic catalog simple example."""
|
|
|
|
from dependency_injector import catalogs
|
|
from dependency_injector import providers
|
|
|
|
|
|
# Defining dynamic catalog:
|
|
catalog = catalogs.DynamicCatalog(factory1=providers.Factory(object),
|
|
factory2=providers.Factory(object))
|
|
|
|
# Creating some objects:
|
|
object1 = catalog.factory1()
|
|
object2 = catalog.factory2()
|
|
|
|
# Making some asserts:
|
|
assert object1 is not object2
|
|
assert isinstance(object1, object)
|
|
assert isinstance(object2, object)
|