2015-11-16 14:28:27 +03:00
|
|
|
"""Declarative catalog simple example."""
|
2015-10-11 15:34:21 +03:00
|
|
|
|
2015-11-14 23:47:33 +03:00
|
|
|
from dependency_injector import catalogs
|
|
|
|
from dependency_injector import providers
|
2015-10-11 15:34:21 +03:00
|
|
|
|
|
|
|
|
2015-11-14 23:47:33 +03:00
|
|
|
class Catalog(catalogs.DeclarativeCatalog):
|
2015-10-11 15:34:21 +03:00
|
|
|
"""Providers catalog."""
|
|
|
|
|
2015-11-14 23:47:33 +03:00
|
|
|
factory1 = providers.Factory(object)
|
|
|
|
""":type: providers.Provider -> object"""
|
2015-10-11 15:34:21 +03:00
|
|
|
|
2015-11-14 23:47:33 +03:00
|
|
|
factory2 = providers.Factory(object)
|
|
|
|
""":type: providers.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)
|