Update resource provider string representation

This commit is contained in:
Roman Mogylatov 2021-02-01 08:44:54 -05:00
parent b02c70e764
commit 7a2c61e9f8
4 changed files with 2028 additions and 2093 deletions

View File

@ -12,6 +12,7 @@ Development version
- Add ``.provides`` attribute to ``Singleton`` and its subclasses.
It's a consistency change to make ``Singleton`` match ``Callable``
and ``Factory`` interfaces.
- Update string representation of ``Resource`` provider.
4.13.2
------

File diff suppressed because it is too large Load Diff

View File

@ -2992,11 +2992,12 @@ cdef class Resource(Provider):
return copied
def __repr__(self):
return (
f'{self.__class__.__name__}({self.__initializer}, '
f'initialized={self.__initialized})'
)
def __str__(self):
"""Return string representation of provider.
:rtype: str
"""
return represent_provider(provider=self, provides=self.__initializer)
@property
def args(self):

View File

@ -337,9 +337,9 @@ class ResourceTests(unittest.TestCase):
self.assertEqual(
repr(provider),
'Resource({0}, initialized={1})'.format(
init_fn,
provider.initialized,
'<dependency_injector.providers.Resource({0}) at {1}>'.format(
repr(init_fn),
hex(id(provider)),
)
)