diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-04 07:47:07 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-04 07:47:07 +0000 |
commit | c7cd694d4f307e65f8e4cc5fb2e724e5f9700dea (patch) | |
tree | 048f4f37fe846d666b9859edb431064dc422b94b /ipalib | |
parent | 71d36aa6a0b9627ae818d116c7240197a62cff74 (diff) | |
download | freeipa.git-c7cd694d4f307e65f8e4cc5fb2e724e5f9700dea.tar.gz freeipa.git-c7cd694d4f307e65f8e4cc5fb2e724e5f9700dea.tar.xz freeipa.git-c7cd694d4f307e65f8e4cc5fb2e724e5f9700dea.zip |
259: Option.__normalize_scalar() now raises a TypeError if not isinstance(value, basestring); updated corresponding unit tests
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/public.py | 4 | ||||
-rw-r--r-- | ipalib/tests/test_public.py | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/ipalib/public.py b/ipalib/public.py index 6220acc0..cc385da1 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -125,8 +125,8 @@ class Option(plugable.ReadOnly): return self.__convert_scalar(value) def __normalize_scalar(self, value): - if type(value) is not self.type.type: - raise_TypeError(value, self.type.type, 'value') + if not isinstance(value, basestring): + raise_TypeError(value, basestring, 'value') return self.__normalize(value) def normalize(self, value): diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index c071832a..6adc393f 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -202,10 +202,10 @@ class test_Option(ClassChecker): # Scenario 2: multivalue=False, normalize=callback o = self.cls(name, doc, t, normalize=callback) - for v in (u'Hello', u'hello'): # Okay - assert o.normalize(v) == u'hello' - for v in [None, 'hello', (u'Hello',)]: # Not unicode - check_TypeError(v, unicode, 'value', o.normalize, v) + for v in (u'Hello', u'hello', 'Hello'): # Okay + assert o.normalize(v) == 'hello' + for v in [None, 42, (u'Hello',)]: # Not basestring + check_TypeError(v, basestring, 'value', o.normalize, v) # Scenario 3: multivalue=True, normalize=None o = self.cls(name, doc, t, multivalue=True) @@ -219,9 +219,9 @@ class test_Option(ClassChecker): assert o.normalize(value) == (u'hello',) for v in (None, u'Hello', [u'hello']): # Not tuple check_TypeError(v, tuple, 'value', o.normalize, v) - fail = 'Hello' # Not unicode + fail = 42 # Not basestring for v in [(fail,), (u'Hello', fail)]: # Non unicode member - check_TypeError(fail, unicode, 'value', o.normalize, v) + check_TypeError(fail, basestring, 'value', o.normalize, v) def test_validate(self): """ |