Make DynamicCatalog.last_overriding and DeclarativeCatalog.last_overriding attributes None by default

This commit is contained in:
Roman Mogilatov 2015-11-25 13:39:50 +02:00
parent b05eefedea
commit ff629989bb
2 changed files with 7 additions and 9 deletions

View File

@ -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

View File

@ -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."""