Fix validators __all__ (#517)
* add new validators from #425 to validators.__all__ * add test for each validator, verifying that it is in validators.__all__ * add changelog entry for #517 * apply autolinting * Make module path absolute
This commit is contained in:
parent
4fe28966e8
commit
957b1982d0
|
@ -0,0 +1 @@
|
|||
Updated ``attr.validators.__all__`` to include new validators added in `#425 <https://github.com/python-attrs/attrs/pull/425>`_.
|
|
@ -7,7 +7,16 @@ from __future__ import absolute_import, division, print_function
|
|||
from ._make import _AndValidator, and_, attrib, attrs
|
||||
|
||||
|
||||
__all__ = ["and_", "in_", "instance_of", "optional", "provides"]
|
||||
__all__ = [
|
||||
"and_",
|
||||
"deep_iterable",
|
||||
"deep_mapping",
|
||||
"in_",
|
||||
"instance_of",
|
||||
"is_callable",
|
||||
"optional",
|
||||
"provides",
|
||||
]
|
||||
|
||||
|
||||
@attrs(repr=False, slots=True, hash=True)
|
||||
|
|
|
@ -31,6 +31,12 @@ class TestInstanceOf(object):
|
|||
Tests for `instance_of`.
|
||||
"""
|
||||
|
||||
def test_in_all(self):
|
||||
"""
|
||||
Verify that this validator is in ``__all__``.
|
||||
"""
|
||||
assert instance_of.__name__ in validator_module.__all__
|
||||
|
||||
def test_success(self):
|
||||
"""
|
||||
Nothing happens if types match.
|
||||
|
@ -86,6 +92,12 @@ def always_fail(_, __, ___):
|
|||
|
||||
|
||||
class TestAnd(object):
|
||||
def test_in_all(self):
|
||||
"""
|
||||
Verify that this validator is in ``__all__``.
|
||||
"""
|
||||
assert and_.__name__ in validator_module.__all__
|
||||
|
||||
def test_success(self):
|
||||
"""
|
||||
Succeeds if all wrapped validators succeed.
|
||||
|
@ -132,6 +144,12 @@ class TestProvides(object):
|
|||
Tests for `provides`.
|
||||
"""
|
||||
|
||||
def test_in_all(self):
|
||||
"""
|
||||
Verify that this validator is in ``__all__``.
|
||||
"""
|
||||
assert provides.__name__ in validator_module.__all__
|
||||
|
||||
def test_success(self):
|
||||
"""
|
||||
Nothing happens if value provides requested interface.
|
||||
|
@ -184,6 +202,12 @@ class TestOptional(object):
|
|||
Tests for `optional`.
|
||||
"""
|
||||
|
||||
def test_in_all(self, validator):
|
||||
"""
|
||||
Verify that this validator is in ``__all__``.
|
||||
"""
|
||||
assert optional.__name__ in validator_module.__all__
|
||||
|
||||
def test_success(self, validator):
|
||||
"""
|
||||
Nothing happens if validator succeeds.
|
||||
|
@ -239,6 +263,12 @@ class TestIn_(object):
|
|||
Tests for `in_`.
|
||||
"""
|
||||
|
||||
def test_in_all(self):
|
||||
"""
|
||||
Verify that this validator is in ``__all__``.
|
||||
"""
|
||||
assert in_.__name__ in validator_module.__all__
|
||||
|
||||
def test_success_with_value(self):
|
||||
"""
|
||||
If the value is in our options, nothing happens.
|
||||
|
@ -281,6 +311,12 @@ class TestDeepIterable(object):
|
|||
Tests for `deep_iterable`.
|
||||
"""
|
||||
|
||||
def test_in_all(self):
|
||||
"""
|
||||
Verify that this validator is in ``__all__``.
|
||||
"""
|
||||
assert deep_iterable.__name__ in validator_module.__all__
|
||||
|
||||
def test_success_member_only(self):
|
||||
"""
|
||||
If the member validator succeeds and the iterable validator is not set,
|
||||
|
@ -395,6 +431,12 @@ class TestDeepMapping(object):
|
|||
Tests for `deep_mapping`.
|
||||
"""
|
||||
|
||||
def test_in_all(self):
|
||||
"""
|
||||
Verify that this validator is in ``__all__``.
|
||||
"""
|
||||
assert deep_mapping.__name__ in validator_module.__all__
|
||||
|
||||
def test_success(self):
|
||||
"""
|
||||
If both the key and value validators succeed, nothing happens.
|
||||
|
@ -485,6 +527,12 @@ class TestIsCallable(object):
|
|||
Tests for `is_callable`.
|
||||
"""
|
||||
|
||||
def test_in_all(self):
|
||||
"""
|
||||
Verify that this validator is in ``__all__``.
|
||||
"""
|
||||
assert is_callable.__name__ in validator_module.__all__
|
||||
|
||||
def test_success(self):
|
||||
"""
|
||||
If the value is callable, nothing happens.
|
||||
|
|
Loading…
Reference in New Issue