summaryrefslogtreecommitdiff
path: root/pylint/extensions
diff options
context:
space:
mode:
authorBruno Daniel <bruno.daniel@blue-yonder.com>2015-05-10 13:04:10 +0200
committerBruno Daniel <bruno.daniel@blue-yonder.com>2015-05-10 13:04:10 +0200
commit8efbf56f67d6aaaee3596a87eb682a0fe4cefbb3 (patch)
tree6bce1e91d8c5c657086ae74434bf34933a1c33c9 /pylint/extensions
parentaf4c5ea511f17aef533b18a01b93fad7a1557310 (diff)
downloadpylint-8efbf56f67d6aaaee3596a87eb682a0fe4cefbb3.tar.gz
unit test for constructor parameter documentation in Google and Numpy style
Diffstat (limited to 'pylint/extensions')
-rw-r--r--pylint/extensions/test/test_check_docs.py69
1 files changed, 68 insertions, 1 deletions
diff --git a/pylint/extensions/test/test_check_docs.py b/pylint/extensions/test/test_check_docs.py
index 8f311ff..bb0b0bf 100644
--- a/pylint/extensions/test/test_check_docs.py
+++ b/pylint/extensions/test/test_check_docs.py
@@ -504,8 +504,9 @@ class SpinxDocCheckerTest(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_function(node)
- def test_constr_params_in_class(self):
+ def test_constr_params_in_class_sphinx(self):
"""Example of a class with missing constructor parameter documentation
+ (Sphinx style)
Everything is completely analogous to functions.
"""
@@ -534,6 +535,72 @@ class SpinxDocCheckerTest(CheckerTestCase):
):
self.checker.visit_class(node)
+ def test_constr_params_in_class_google(self):
+ """Example of a class with missing constructor parameter documentation
+ (Google style)
+
+ Everything is completely analogous to functions.
+ """
+ node = test_utils.extract_node("""
+ class ClassFoo(object):
+ '''docstring foo
+
+ Args:
+ y: bla
+
+ missing constructor parameter documentation
+ '''
+
+ def __init__(self, x, y):
+ pass
+
+ """)
+ with self.assertAddsMessages(
+ Message(
+ msg_id='missing-sphinx-param',
+ node=node,
+ args=('x',)),
+ Message(
+ msg_id='missing-sphinx-type',
+ node=node,
+ args=('x, y',))
+ ):
+ self.checker.visit_class(node)
+
+ def test_constr_params_in_class_numpy(self):
+ """Example of a class with missing constructor parameter documentation
+ (Sphinx style)
+
+ Everything is completely analogous to functions.
+ """
+ node = test_utils.extract_node("""
+ class ClassFoo(object):
+ '''docstring foo
+
+ Parameters
+ ----------
+ y:
+ bla
+
+ missing constructor parameter documentation
+ '''
+
+ def __init__(self, x, y):
+ pass
+
+ """)
+ with self.assertAddsMessages(
+ Message(
+ msg_id='missing-sphinx-param',
+ node=node,
+ args=('x',)),
+ Message(
+ msg_id='missing-sphinx-type',
+ node=node,
+ args=('x, y',))
+ ):
+ self.checker.visit_class(node)
+
if __name__ == '__main__':
unittest.main()