summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-12-18 02:08:41 -0700
committerJason Gerard DeRose <jderose@redhat.com>2008-12-18 02:08:41 -0700
commit4d1681176afc45c57fb4316892f939bda1bacf1d (patch)
tree04abc4122c0dc3ab1d8de54858b94f72af0e5f71 /ipalib
parentcb2f294cfef9b47e03b82c85cf1db7e7bc3574ef (diff)
downloadfreeipa-4d1681176afc45c57fb4316892f939bda1bacf1d.tar.gz
freeipa-4d1681176afc45c57fb4316892f939bda1bacf1d.tar.xz
freeipa-4d1681176afc45c57fb4316892f939bda1bacf1d.zip
New Param: added unit tests for TypeError cases in DefaultFrom.__init__()
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/constants.py2
-rw-r--r--ipalib/parameter.py8
2 files changed, 7 insertions, 3 deletions
diff --git a/ipalib/constants.py b/ipalib/constants.py
index ad1e3f7c..ef2aef72 100644
--- a/ipalib/constants.py
+++ b/ipalib/constants.py
@@ -29,7 +29,7 @@ NULLS = (None, '', u'', tuple(), [])
TYPE_ERROR = '%s: need a %r; got %r (which is a %r)'
-CALLABLE_ERROR = '%s: need a callable; got %r (a %r)'
+CALLABLE_ERROR = '%s: need a callable; got %r (which is a %r)'
# Used for a tab (or indentation level) when formatting for CLI:
diff --git a/ipalib/parameter.py b/ipalib/parameter.py
index ca578cd9..fca95b0e 100644
--- a/ipalib/parameter.py
+++ b/ipalib/parameter.py
@@ -103,7 +103,9 @@ class DefaultFrom(ReadOnly):
:param keys: Optional keys used for source values.
"""
if not callable(callback):
- raise TypeError('callback must be callable; got %r' % callback)
+ raise TypeError(
+ CALLABLE_ERROR % ('callback', callback, type(callback))
+ )
self.callback = callback
if len(keys) == 0:
fc = callback.func_code
@@ -112,7 +114,9 @@ class DefaultFrom(ReadOnly):
self.keys = keys
for key in self.keys:
if type(key) is not str:
- raise_TypeError(key, str, 'keys')
+ raise TypeError(
+ TYPE_ERROR % ('keys', str, key, type(key))
+ )
lock(self)
def __call__(self, **kw):