mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-27 03:54:00 +03:00
23 lines
494 B
Python
23 lines
494 B
Python
"""Declarative catalog example."""
|
|
|
|
import dependency_injector as di
|
|
|
|
|
|
class Catalog(di.DeclarativeCatalog):
|
|
"""Providers catalog."""
|
|
|
|
factory1 = di.Factory(object)
|
|
""":type: di.Provider -> object"""
|
|
|
|
factory2 = di.Factory(object)
|
|
""":type: di.Provider -> 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)
|