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. - Add ``.provides`` attribute to ``Singleton`` and its subclasses.
It's a consistency change to make ``Singleton`` match ``Callable`` It's a consistency change to make ``Singleton`` match ``Callable``
and ``Factory`` interfaces. and ``Factory`` interfaces.
- Update string representation of ``Resource`` provider.
4.13.2 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 return copied
def __repr__(self): def __str__(self):
return ( """Return string representation of provider.
f'{self.__class__.__name__}({self.__initializer}, '
f'initialized={self.__initialized})' :rtype: str
) """
return represent_provider(provider=self, provides=self.__initializer)
@property @property
def args(self): def args(self):

View File

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