python-dependency-injector/examples/providers/factory.py
2015-06-05 11:29:36 +03:00

19 lines
368 B
Python

"""`Factory` providers example."""
from objects.providers import Factory
class User(object):
"""Example class User."""
# Factory provider creates new instance of specified class on every call.
users_factory = Factory(User)
user1 = users_factory()
user2 = users_factory()
assert user1 is not user2
assert isinstance(user1, User) and isinstance(user2, User)