mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-14 02:11:56 -06:00
240: Small change in tstutil.check_TypeError(), cleaned up use of check_TypeError() in test_Option.test_normalize()
This commit is contained in:
parent
085ea3f62f
commit
9548b4b951
@ -185,8 +185,6 @@ class test_Option(ClassChecker):
|
||||
for v in (u'Hello', u'hello'): # Okay
|
||||
assert o.normalize(v) == u'hello'
|
||||
for v in [None, 'hello', (u'Hello',)]: # Not unicode
|
||||
e = raises(TypeError, o.normalize, v)
|
||||
assert str(e) == errors.TYPE_FORMAT % ('value', unicode, v)
|
||||
check_TypeError(v, unicode, 'value', o.normalize, v)
|
||||
|
||||
# Scenario 3: multivalue=True, normalize=None
|
||||
@ -200,13 +198,10 @@ class test_Option(ClassChecker):
|
||||
for value in [(u'Hello',), (u'hello',)]: # Okay
|
||||
assert o.normalize(value) == (u'hello',)
|
||||
for v in (None, u'Hello', [u'hello']): # Not tuple
|
||||
e = raises(TypeError, o.normalize, v)
|
||||
assert str(e) == errors.TYPE_FORMAT % ('value', tuple, v)
|
||||
check_TypeError(v, tuple, 'value', o.normalize, v)
|
||||
for v in [('Hello',), (u'Hello', 'Hello')]: # Non unicode member
|
||||
e = raises(TypeError, o.normalize, v)
|
||||
assert str(e) == errors.TYPE_FORMAT % ('value', unicode, 'Hello')
|
||||
check_TypeError('Hello', unicode, 'value', o.normalize, v)
|
||||
fail = 'Hello' # Not unicode
|
||||
for v in [(fail,), (u'Hello', fail)]: # Non unicode member
|
||||
check_TypeError(fail, unicode, 'value', o.normalize, v)
|
||||
|
||||
def test_validate(self):
|
||||
"""
|
||||
|
@ -139,9 +139,9 @@ def check_TypeError(value, type_, name, callback, *args, **kw):
|
||||
Tests a standard TypeError raised with `errors.raise_TypeError`.
|
||||
"""
|
||||
e = raises(TypeError, callback, *args, **kw)
|
||||
assert e.value == value
|
||||
assert type(e.value) is type(value)
|
||||
assert e.value is value
|
||||
assert e.type is type_
|
||||
assert e.name == name
|
||||
assert type(e.name) is str
|
||||
assert str(e) == errors.TYPE_FORMAT % (name, type_, value)
|
||||
return e
|
||||
|
Loading…
Reference in New Issue
Block a user