summaryrefslogtreecommitdiffstats
path: root/nova/validate.py
diff options
context:
space:
mode:
authorJoshua McKenty <jmckenty@gmail.com>2010-06-24 04:11:56 +0100
committerandy <github@anarkystic.com>2010-06-24 04:11:56 +0100
commit108f97f5d7854cfed2c006112a91873ac4f2ed1a (patch)
tree0bd194e5315920330ef6daf6aab09ad3ccbc413b /nova/validate.py
parent6ebd60377382a23d37eea9e65df38f0f581252fa (diff)
downloadnova-108f97f5d7854cfed2c006112a91873ac4f2ed1a.tar.gz
nova-108f97f5d7854cfed2c006112a91873ac4f2ed1a.tar.xz
nova-108f97f5d7854cfed2c006112a91873ac4f2ed1a.zip
First pass at validation unit tests. Haven't figured out class methods yet.
Diffstat (limited to 'nova/validate.py')
-rw-r--r--nova/validate.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/nova/validate.py b/nova/validate.py
index d1358d402..e96a47059 100644
--- a/nova/validate.py
+++ b/nova/validate.py
@@ -63,17 +63,17 @@ def typetest(**argchecks):
def onCall(*pargs, **kargs):
positionals = list(allargs)[:len(pargs)]
- for (argname, type) in argchecks.items():
- if argname in kargs:
- if not isinstance(kargs[argname], type):
+ for (argname, typeof) in argchecks.items():
+ if argname in kargs:
+ if not isinstance(kargs[argname], typeof):
errmsg = '{0} argument "{1}" not of type {2}'
- errmsg = errmsg.format(funcname, argname, type)
+ errmsg = errmsg.format(funcname, argname, typeof)
raise TypeError(errmsg)
elif argname in positionals:
position = positionals.index(argname)
- if not isinstance(pargs[position], type):
- errmsg = '{0} argument "{1}" not of type {2}'
- errmsg = errmsg.format(funcname, argname, type)
+ if not isinstance(pargs[position], typeof):
+ errmsg = '{0} argument "{1}" with value of {2} not of type {3}'
+ errmsg = errmsg.format(funcname, argname, pargs[position], typeof)
raise TypeError(errmsg)
else:
pass