mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-29 04:53:59 +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):
|
def last_overriding(self):
|
||||||
"""Read-only reference to the last overriding catalog, if any.
|
"""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] if self.overridden_by else None
|
||||||
return self.overridden_by[-1]
|
|
||||||
except (TypeError, IndexError):
|
|
||||||
raise Error('Catalog {0} is not overridden'.format(self))
|
|
||||||
|
|
||||||
def override(self, overriding):
|
def override(self, overriding):
|
||||||
"""Override current catalog providers by overriding catalog providers.
|
"""Override current catalog providers by overriding catalog providers.
|
||||||
|
@ -477,7 +475,8 @@ class DeclarativeCatalogMetaClass(type):
|
||||||
def last_overriding(cls):
|
def last_overriding(cls):
|
||||||
"""Read-only reference to the last overriding catalog, if any.
|
"""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
|
return cls._catalog.last_overriding
|
||||||
|
|
||||||
|
@ -605,7 +604,7 @@ class DeclarativeCatalog(object):
|
||||||
last_overriding = None
|
last_overriding = None
|
||||||
"""Read-only reference to the last overriding catalog, if any.
|
"""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
|
_catalog = DynamicCatalog
|
||||||
|
|
|
@ -506,8 +506,7 @@ class OverrideTests(unittest.TestCase):
|
||||||
|
|
||||||
def test_last_overriding_on_not_overridden(self):
|
def test_last_overriding_on_not_overridden(self):
|
||||||
"""Test catalog last_overriding property on not overridden catalog."""
|
"""Test catalog last_overriding property on not overridden catalog."""
|
||||||
with self.assertRaises(errors.Error):
|
self.assertIsNone(CatalogA.last_overriding)
|
||||||
CatalogA.last_overriding
|
|
||||||
|
|
||||||
def test_reset_last_overriding(self):
|
def test_reset_last_overriding(self):
|
||||||
"""Test resetting last overriding catalog."""
|
"""Test resetting last overriding catalog."""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user