Minor fixes
This commit is contained in:
parent
708533239d
commit
3051fbfcd3
|
@ -106,9 +106,9 @@ class _OptionalValidator(object):
|
||||||
def optional(validator):
|
def optional(validator):
|
||||||
"""
|
"""
|
||||||
A validator that makes an attribute optional. An optional attribute is one
|
A validator that makes an attribute optional. An optional attribute is one
|
||||||
which can be set to None in addition to satisfying the requirements of the
|
which can be set to ``None`` in addition to satisfying the requirements of
|
||||||
sub-validator.
|
the sub-validator.
|
||||||
|
|
||||||
:param validator: Any other validator you wish to make optional.
|
:param validator: A validator that is used for non-``None`` values.
|
||||||
"""
|
"""
|
||||||
return _OptionalValidator(validator)
|
return _OptionalValidator(validator)
|
||||||
|
|
|
@ -128,13 +128,6 @@ class TestOptional(object):
|
||||||
v = optional(instance_of(int))
|
v = optional(instance_of(int))
|
||||||
v(None, simple_attr("test"), None)
|
v(None, simple_attr("test"), None)
|
||||||
|
|
||||||
def test_subclass(self):
|
|
||||||
"""
|
|
||||||
Subclasses are accepted too.
|
|
||||||
"""
|
|
||||||
v = optional(instance_of(int))
|
|
||||||
v(None, simple_attr("test"), True)
|
|
||||||
|
|
||||||
def test_fail(self):
|
def test_fail(self):
|
||||||
"""
|
"""
|
||||||
Raises `TypeError` on wrong types.
|
Raises `TypeError` on wrong types.
|
||||||
|
|
Loading…
Reference in New Issue