Fix py38 error

Change-Id: I43abd65afab57053f47c6aecd2a2ba2e3fc26472
This commit is contained in:
zhurong 2020-04-22 18:38:39 -07:00
parent 19e128023c
commit c8d75bb1f9
3 changed files with 5 additions and 7 deletions

View File

@ -18,7 +18,8 @@ class Registry(object):
"""Allow domain objects to be loaded by name."""
def __getattr__(self, name):
return self.impls[name]
if name in self.impls:
return self.impls[name]
def add(self, interface, cls):
"""Register an implementation for a class."""

View File

@ -17,8 +17,6 @@ test_service
Tests for `solum.common.service` module.
"""
import testtools
from solum.common import service
from solum import objects
from solum.objects import component as abstract
@ -29,8 +27,8 @@ class TestService(base.BaseTestCase):
def test_prepare_invokes_object_load(self):
objects.registry.clear()
with testtools.ExpectedException(KeyError):
objects.registry.Component()
objects.registry.Component
objects.load()
service.prepare_service([])
self.assertTrue(issubclass(objects.registry.Component,
abstract.Component))

View File

@ -43,8 +43,7 @@ class TestObjectsSqlalchemy(tests.BaseTestCase):
objects.registry.clear()
with testtools.ExpectedException(KeyError):
objects.registry.Component
objects.registry.Component
objects.load()