Merge "Make sure ConfigType is an abstract class"
This commit is contained in:
commit
e7bb0e142a
@ -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()
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user