2015-11-13 19:58:29 +03:00
|
|
|
"""Declarative catalog example."""
|
2015-10-11 15:34:21 +03:00
|
|
|
|
|
|
|
import dependency_injector as di
|
|
|
|
|
|
|
|
|
2015-11-10 11:42:29 +03:00
|
|
|
class Catalog(di.DeclarativeCatalog):
|
2015-10-11 15:34:21 +03:00
|
|
|
"""Providers catalog."""
|
|
|
|
|
|
|
|
factory1 = di.Factory(object)
|
2015-10-26 13:52:52 +03:00
|
|
|
""":type: di.Provider -> object"""
|
2015-10-11 15:34:21 +03:00
|
|
|
|
|
|
|
factory2 = di.Factory(object)
|
2015-10-26 13:52:52 +03:00
|
|
|
""":type: di.Provider -> object"""
|
2015-10-11 15:34:21 +03:00
|
|
|
|
|
|
|
# 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)
|