Fix a typo in Enum error path

This fixes a bug that I found while making another change, along with
a test that exercises the code that pokes it.

Change-Id: Ibb1ca5e171c6329a46a5d853a3ab8613f58d067f
This commit is contained in:
Dan Smith 2016-04-25 08:36:33 -07:00
parent f7e5f8e67a
commit 59ac1d009d
2 changed files with 10 additions and 1 deletions

View File

@ -685,7 +685,7 @@ class BaseEnumField(AutoTypedField):
if not isinstance(self.AUTO_TYPE, Enum):
raise exception.EnumFieldInvalid(
typename=self.AUTO_TYPE.__class__.__name,
typename=self.AUTO_TYPE.__class__.__name__,
fieldname=self.__class__.__name__)
super(BaseEnumField, self).__init__(**kwargs)

View File

@ -296,6 +296,15 @@ class TestEnum(TestField):
self.assertRaises(exception.EnumValidValuesInvalidError,
fields.EnumField, True)
def test_enum_subclass_check(self):
def _test():
class BrokenEnumField(fields.BaseEnumField):
AUTO_TYPE = int
BrokenEnumField()
self.assertRaises(exception.EnumFieldInvalid, _test)
class TestStateMachine(TestField):