From f816293b6bc8ceb7089ea5cf03b63b06b3491893 Mon Sep 17 00:00:00 2001 From: Bruno Daniel Date: Sun, 10 May 2015 12:54:03 +0200 Subject: unit tests for correctly documented parameters and return values (all 3 styles) --- pylint/extensions/test/test_check_docs.py | 55 +++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'pylint/extensions') diff --git a/pylint/extensions/test/test_check_docs.py b/pylint/extensions/test/test_check_docs.py index 642ceb1..47b264f 100644 --- a/pylint/extensions/test/test_check_docs.py +++ b/pylint/extensions/test/test_check_docs.py @@ -209,9 +209,9 @@ class SpinxDocCheckerTest(CheckerTestCase): ): self.checker.visit_class(node) - def test_existing_func_params_in_docstring(self): + def test_existing_func_params_in_sphinx_docstring(self): """Example of a function with correctly documented parameters and - return values + return values (Sphinx style) """ node = test_utils.extract_node(""" def function_foo(xarg, yarg, zarg): @@ -233,6 +233,57 @@ class SpinxDocCheckerTest(CheckerTestCase): with self.assertNoMessages(): self.checker.visit_function(node) + def test_existing_func_params_in_google_docstring(self): + """Example of a function with correctly documented parameters and + return values (Google style) + """ + node = test_utils.extract_node(""" + def function_foo(xarg, yarg, zarg): + '''function foo ... + + Args: + xarg (int): bla xarg + yarg (float): bla + bla yarg + + zarg (int): bla zarg + + Returns: + sum (float) + ''' + return xarg + yarg + """) + with self.assertNoMessages(): + self.checker.visit_function(node) + + def test_existing_func_params_in_numpy_docstring(self): + """Example of a function with correctly documented parameters and + return values (Numpy style) + """ + node = test_utils.extract_node(""" + def function_foo(xarg, yarg, zarg): + '''function foo ... + + Parameters + ---------- + xarg: int + bla xarg + yarg: float + bla yarg + + zarg: int + bla zarg + + Returns + ------- + float + sum + ''' + return xarg + yarg + """) + with self.assertNoMessages(): + self.checker.visit_function(node) + def test_wrong_name_of_func_params_in_docstring(self): """Example of functions with inconsistent parameter names in the signature and in the documentation -- cgit v1.2.1