Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validators __all__ #517

Merged
merged 5 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/517.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated ``attr.validators.__all__`` to include new validators added in `#425 <https:/python-attrs/attrs/pull/425>`_.
11 changes: 10 additions & 1 deletion src/attr/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@
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)
Expand Down
48 changes: 48 additions & 0 deletions tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down