Merge "Make sure ConfigType is an abstract class"

This commit is contained in:
Jenkins 2016-05-24 19:50:38 +00:00 committed by Gerrit Code Review
commit e7bb0e142a
2 changed files with 20 additions and 0 deletions

View File

@ -18,6 +18,25 @@ import unittest
from oslo_config import types
class ConfigTypeTests(unittest.TestCase):
def test_none_concrete_class(self):
class MyString(types.ConfigType):
def __init__(self, type_name='mystring value'):
super(MyString, self).__init__(type_name=type_name)
self.assertRaises(TypeError, MyString)
def test_concrete_class(self):
class MyString(types.ConfigType):
def __init__(self, type_name='mystring value'):
super(MyString, self).__init__(type_name=type_name)
def _formatter(self, value):
return value
MyString()
class TypeTestHelper(object):
def setUp(self):
super(TypeTestHelper, self).setUp()

View File

@ -28,6 +28,7 @@ import netaddr
import six
@six.add_metaclass(abc.ABCMeta)
class ConfigType(object):
def __init__(self, type_name='unknown type'):
self.type_name = type_name