mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-26 03:23:58 +03:00
19 lines
368 B
Python
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)
|