From 957b1982d0d635e6e367bced0088ecc25fa4bc14 Mon Sep 17 00:00:00 2001 From: Matt Bullock Date: Wed, 13 Mar 2019 06:37:49 -0700 Subject: [PATCH] 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 --- changelog.d/517.bugfix.rst | 1 + src/attr/validators.py | 11 ++++++++- tests/test_validators.py | 48 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 changelog.d/517.bugfix.rst diff --git a/changelog.d/517.bugfix.rst b/changelog.d/517.bugfix.rst new file mode 100644 index 000000000..50d3e33dd --- /dev/null +++ b/changelog.d/517.bugfix.rst @@ -0,0 +1 @@ +Updated ``attr.validators.__all__`` to include new validators added in `#425 `_. diff --git a/src/attr/validators.py b/src/attr/validators.py index 7fc4446be..9c39dd208 100644 --- a/src/attr/validators.py +++ b/src/attr/validators.py @@ -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) diff --git a/tests/test_validators.py b/tests/test_validators.py index 3fe5e1e05..30bf672cf 100644 --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -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.