mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-25 11:04:01 +03:00
Make DynamicCatalog.last_overriding and DeclarativeCatalog.last_overriding attributes None by default
This commit is contained in:
parent
b05eefedea
commit
ff629989bb
|
@ -235,12 +235,10 @@ class DynamicCatalog(object):
|
|||
def last_overriding(self):
|
||||
"""Read-only reference to the last overriding catalog, if any.
|
||||
|
||||
:type: :py:class:`DeclarativeCatalog` | :py:class:`DynamicCatalog`
|
||||
:type: :py:class:`DeclarativeCatalog` | :py:class:`DynamicCatalog` |
|
||||
None
|
||||
"""
|
||||
try:
|
||||
return self.overridden_by[-1]
|
||||
except (TypeError, IndexError):
|
||||
raise Error('Catalog {0} is not overridden'.format(self))
|
||||
return self.overridden_by[-1] if self.overridden_by else None
|
||||
|
||||
def override(self, overriding):
|
||||
"""Override current catalog providers by overriding catalog providers.
|
||||
|
@ -477,7 +475,8 @@ class DeclarativeCatalogMetaClass(type):
|
|||
def last_overriding(cls):
|
||||
"""Read-only reference to the last overriding catalog, if any.
|
||||
|
||||
:type: :py:class:`DeclarativeCatalog` | :py:class:`DynamicCatalog`
|
||||
:type: :py:class:`DeclarativeCatalog` | :py:class:`DynamicCatalog` |
|
||||
None
|
||||
"""
|
||||
return cls._catalog.last_overriding
|
||||
|
||||
|
@ -605,7 +604,7 @@ class DeclarativeCatalog(object):
|
|||
last_overriding = None
|
||||
"""Read-only reference to the last overriding catalog, if any.
|
||||
|
||||
:type: :py:class:`DeclarativeCatalog` | :py:class:`DynamicCatalog`
|
||||
:type: :py:class:`DeclarativeCatalog` | :py:class:`DynamicCatalog` | None
|
||||
"""
|
||||
|
||||
_catalog = DynamicCatalog
|
||||
|
|
|
@ -506,8 +506,7 @@ class OverrideTests(unittest.TestCase):
|
|||
|
||||
def test_last_overriding_on_not_overridden(self):
|
||||
"""Test catalog last_overriding property on not overridden catalog."""
|
||||
with self.assertRaises(errors.Error):
|
||||
CatalogA.last_overriding
|
||||
self.assertIsNone(CatalogA.last_overriding)
|
||||
|
||||
def test_reset_last_overriding(self):
|
||||
"""Test resetting last overriding catalog."""
|
||||
|
|
Loading…
Reference in New Issue
Block a user