summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipalib/plugable.py3
-rw-r--r--ipalib/tests/test_plugable.py2
2 files changed, 4 insertions, 1 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 811a5527..9880b0a0 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -28,6 +28,7 @@ http://docs.python.org/ref/sequence-types.html
import re
import inspect
import errors
+from errors import check_type, check_isinstance
class ReadOnly(object):
@@ -466,7 +467,7 @@ def check_name(name):
:param name: Identifier to test.
"""
- assert type(name) is str, 'must be %r' % str
+ check_type(name, str, 'name')
regex = r'^[a-z][_a-z0-9]*[a-z0-9]$'
if re.match(regex, name) is None:
raise errors.NameSpaceError(name, regex)
diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py
index 44067b80..ec33989d 100644
--- a/ipalib/tests/test_plugable.py
+++ b/ipalib/tests/test_plugable.py
@@ -549,6 +549,8 @@ def test_check_name():
]
for name in okay:
assert name is f(name)
+ e = raises(TypeError, f, unicode(name))
+ assert str(e) == errors.TYPE_FORMAT % ('name', str, unicode(name))
for name in nope:
raises(errors.NameSpaceError, f, name)
for name in okay: