Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
srobuttiteraki committed Mar 8, 2019
1 parent 77317fa commit 633107f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/attr/_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ def _add_method_dunders(self, method):
pass

try:
method.__doc__ = "Method generated by attrs for {}".format(
method.__doc__ = "Method generated by attrs for {}.".format(
self._cls.__qualname__
)
except AttributeError:
Expand Down
26 changes: 24 additions & 2 deletions tests/test_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -1483,10 +1483,32 @@ class B(A):


class TestDocs:
def test_init_docs(self):
@pytest.mark.parametrize(
"meth_name",
[
"__init__",
"__repr__",
"__eq__",
"__ne__",
"__lt__",
"__le__",
"__gt__",
"__ge__",
],
)
def test_docs(self, meth_name):
"""
Tests the presence and correctness of the documentation
for the generated methods
"""

@attr.s
class A(object):
pass

if hasattr(A, "__qualname__"):
assert A.__qualname__ in A.__init__.__doc__
method = getattr(A, meth_name)
expected = "Method generated by attrs for {}.".format(
A.__qualname__
)
assert expected == method.__doc__

0 comments on commit 633107f

Please sign in to comment.