diff options
author | Bruno Daniel <bruno.daniel@blue-yonder.com> | 2015-05-10 12:47:59 +0200 |
---|---|---|
committer | Bruno Daniel <bruno.daniel@blue-yonder.com> | 2015-05-10 12:47:59 +0200 |
commit | 026798cbbc947b18bb0be65a2fa3d14ee17d0090 (patch) | |
tree | ad54a9995b49d84a7d4ff55ebca1ead81d409bd3 /pylint/extensions | |
parent | 01c261e5eb98a69bf34bf2d130a7e3ec98a4b3a9 (diff) | |
download | pylint-026798cbbc947b18bb0be65a2fa3d14ee17d0090.tar.gz |
unit test for Numpy style parameter documentation; improvements of other unit tests
Diffstat (limited to 'pylint/extensions')
-rw-r--r-- | pylint/extensions/test/test_check_docs.py | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/pylint/extensions/test/test_check_docs.py b/pylint/extensions/test/test_check_docs.py index 5a4fb8a..6df0a9d 100644 --- a/pylint/extensions/test/test_check_docs.py +++ b/pylint/extensions/test/test_check_docs.py @@ -21,7 +21,7 @@ class SpinxDocCheckerTest(CheckerTestCase): self.assertEqual(space_indentation('\n abc'), 0) self.assertEqual(space_indentation(' \n abc'), 3) - def test_missing_func_params_in_docstring_sphinx(self): + def test_missing_func_params_in_sphinx_docstring(self): """Example of a function with missing Sphinx parameter documentation in the docstring """ @@ -32,8 +32,7 @@ class SpinxDocCheckerTest(CheckerTestCase): :param x: bla :param int z: bar - - missing parameter documentation''' + ''' pass """) with self.assertAddsMessages( @@ -48,7 +47,7 @@ class SpinxDocCheckerTest(CheckerTestCase): ): self.checker.visit_function(node) - def test_missing_func_params_in_docstring_google(self): + def test_missing_func_params_in_google_docstring(self): """Example of a function with missing Google style parameter documentation in the docstring """ @@ -59,8 +58,40 @@ class SpinxDocCheckerTest(CheckerTestCase): Args: x: bla z (int): bar - - missing parameter documentation''' + + some other stuff + ''' + pass + """) + with self.assertAddsMessages( + Message( + msg_id='missing-sphinx-param', + node=node, + args=('y',)), + Message( + msg_id='missing-sphinx-type', + node=node, + args=('x, y',)) + ): + self.checker.visit_function(node) + + def test_missing_func_params_in_numpy_docstring(self): + """Example of a function with missing NumPy style parameter + documentation in the docstring + """ + node = test_utils.extract_node(""" + def function_foo(x, y, z): + '''docstring ... + + Parameters + ---------- + x: + bla + z: int + bar + + some other stuff + ''' pass """) with self.assertAddsMessages( @@ -75,8 +106,8 @@ class SpinxDocCheckerTest(CheckerTestCase): ): self.checker.visit_function(node) - def test_tolerate_no_sphinx_param_documentation_at_all(self): - """Example of a function with no Sphinx parameter documentation at all + def test_tolerate_no_param_documentation_at_all(self): + """Example of a function with no parameter documentation at all No error message is emitted. """ @@ -168,7 +199,7 @@ class SpinxDocCheckerTest(CheckerTestCase): Message( msg_id='missing-sphinx-type', node=node, - args=('yarg, yarg1, zarg',)), + args=('yarg, yarg1, zarg, zarg1',)), ): self.checker.visit_function(node) |