212: Type.__init__() now can also raise TypeError; added unit tests for Type.__init__()

This commit is contained in:
Jason Gerard DeRose
2008-08-28 02:45:04 +00:00
parent 81d0726f5e
commit d121a729aa
2 changed files with 21 additions and 3 deletions

View File

@@ -52,11 +52,11 @@ class Type(ReadOnly):
"""
def __init__(self, type_):
if type(type_) is not type:
raise TypeError('%r is not %r' % (type(type_), type))
allowed = (bool, int, float, unicode)
if type_ not in allowed:
raise ValueError(
'type_ must be in %r, got %r' % (type_, allowed)
)
raise ValueError('not an allowed type: %r' % type_)
self.type = type_
lock(self)