summaryrefslogtreecommitdiff
path: root/pylint/extensions
diff options
context:
space:
mode:
authorBruno Daniel <bruno.daniel@blue-yonder.com>2015-05-10 13:00:36 +0200
committerBruno Daniel <bruno.daniel@blue-yonder.com>2015-05-10 13:00:36 +0200
commit96d2e38b51b59fa30c130cfdfae15f58ac8c6709 (patch)
tree7c0a26e560935f2fe6708f953a6bd94a64f774f4 /pylint/extensions
parentf816293b6bc8ceb7089ea5cf03b63b06b3491893 (diff)
downloadpylint-96d2e38b51b59fa30c130cfdfae15f58ac8c6709.tar.gz
unit test for wrong names of function params in Google and numpy style docstrings
Diffstat (limited to 'pylint/extensions')
-rw-r--r--pylint/extensions/test/test_check_docs.py112
1 files changed, 110 insertions, 2 deletions
diff --git a/pylint/extensions/test/test_check_docs.py b/pylint/extensions/test/test_check_docs.py
index 47b264f..b8e61e7 100644
--- a/pylint/extensions/test/test_check_docs.py
+++ b/pylint/extensions/test/test_check_docs.py
@@ -284,9 +284,9 @@ class SpinxDocCheckerTest(CheckerTestCase):
with self.assertNoMessages():
self.checker.visit_function(node)
- def test_wrong_name_of_func_params_in_docstring(self):
+ def test_wrong_name_of_func_params_in_sphinx_docstring(self):
"""Example of functions with inconsistent parameter names in the
- signature and in the documentation
+ signature and in the Sphinx style documentation
"""
node = test_utils.extract_node("""
def function_foo(xarg, yarg, zarg):
@@ -337,6 +337,114 @@ class SpinxDocCheckerTest(CheckerTestCase):
):
self.checker.visit_function(node)
+ def test_wrong_name_of_func_params_in_google_docstring(self):
+ """Example of functions with inconsistent parameter names in the
+ signature and in the Google style documentation
+ """
+ node = test_utils.extract_node("""
+ def function_foo(xarg, yarg, zarg):
+ '''function foo ...
+
+ Args:
+ xarg1 (int): bla xarg
+ yarg (float): bla yarg
+
+ zarg1 (str): bla zarg
+ '''
+ return xarg + yarg
+ """)
+ with self.assertAddsMessages(
+ Message(
+ msg_id='missing-sphinx-param',
+ node=node,
+ args=('xarg, xarg1, zarg, zarg1',)),
+ Message(
+ msg_id='missing-sphinx-type',
+ node=node,
+ args=('xarg, xarg1, zarg, zarg1',)),
+ ):
+ self.checker.visit_function(node)
+
+ node = test_utils.extract_node("""
+ def function_foo(xarg, yarg):
+ '''function foo ...
+
+ Args:
+ yarg1 (float): bla yarg
+
+ For the other parameters, see bla.
+ '''
+ return xarg + yarg
+ """)
+ with self.assertAddsMessages(
+ Message(
+ msg_id='missing-sphinx-param',
+ node=node,
+ args=('yarg1',)),
+ Message(
+ msg_id='missing-sphinx-type',
+ node=node,
+ args=('yarg1',))
+ ):
+ self.checker.visit_function(node)
+
+ def test_wrong_name_of_func_params_in_numpy_docstring(self):
+ """Example of functions with inconsistent parameter names in the
+ signature and in the Numpy style documentation
+ """
+ node = test_utils.extract_node("""
+ def function_foo(xarg, yarg, zarg):
+ '''function foo ...
+
+ Parameters
+ ----------
+ xarg1: int
+ bla xarg
+ yarg: float
+ bla yarg
+
+ zarg1: str
+ bla zarg
+ '''
+ return xarg + yarg
+ """)
+ with self.assertAddsMessages(
+ Message(
+ msg_id='missing-sphinx-param',
+ node=node,
+ args=('xarg, xarg1, zarg, zarg1',)),
+ Message(
+ msg_id='missing-sphinx-type',
+ node=node,
+ args=('xarg, xarg1, zarg, zarg1',)),
+ ):
+ self.checker.visit_function(node)
+
+ node = test_utils.extract_node("""
+ def function_foo(xarg, yarg):
+ '''function foo ...
+
+ Parameters
+ ----------
+ yarg1: float
+ bla yarg
+
+ For the other parameters, see bla.
+ '''
+ return xarg + yarg
+ """)
+ with self.assertAddsMessages(
+ Message(
+ msg_id='missing-sphinx-param',
+ node=node,
+ args=('yarg1',)),
+ Message(
+ msg_id='missing-sphinx-type',
+ node=node,
+ args=('yarg1',))
+ ):
+ self.checker.visit_function(node)
+
def test_see_sentence_for_func_params_in_docstring(self):
"""Example for the usage of "For the other parameters, see" to avoid
too many repetitions, e.g. in functions or methods adhering to a