2
0
mirror of https://github.com/openkmip/pykmip synced 2025-12-16 00:04:26 +00:00

Adding test case for bug with unsigned Enumeration encoding

This change adds a test case that verifies a fix for a bug with how
Enumerations were encoded as signed instead of unsigned integers. The
validation check for Enumerations has also been updated to be more
concise.
This commit is contained in:
Peter Hamilton
2015-06-16 14:33:56 -04:00
parent 4d92d1fa95
commit 64d30343a1
2 changed files with 18 additions and 4 deletions

View File

@@ -415,10 +415,9 @@ class Enumeration(Integer):
def __validate(self):
if self.enum is not None:
if type(self.enum) is not self.ENUM_TYPE:
msg = ErrorStrings.BAD_EXP_RECV
raise TypeError(msg.format(Enumeration.__name__, 'value',
Enum, type(self.enum)))
if not isinstance(self.enum, Enum):
raise TypeError("expected {0}, observed {1}".format(
type(self.enum), Enum))
def __repr__(self):
return "{0}(value={1})".format(type(self).__name__, self.enum)