diff options
author | Logan Miller <14319179+komodo472@users.noreply.github.com> | 2021-01-09 02:48:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-09 10:48:25 +0100 |
commit | 168bee7f23d9956c12b419b18aa9f5974151e3d7 (patch) | |
tree | 6bca70a85d3009194b061233e8d191c7d1bbeafa /tests/extensions/test_check_docs.py | |
parent | e2c06c0fd627993356986115426287ac4ae6098a (diff) | |
download | pylint-git-168bee7f23d9956c12b419b18aa9f5974151e3d7.tar.gz |
Enforce docparams consistently when docstring is not present (#3916)
* fix #2738
* doc updates
* add functional tests
* fix formattting
* fix formatting
Diffstat (limited to 'tests/extensions/test_check_docs.py')
-rw-r--r-- | tests/extensions/test_check_docs.py | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/extensions/test_check_docs.py b/tests/extensions/test_check_docs.py index a7b863740..a40e96220 100644 --- a/tests/extensions/test_check_docs.py +++ b/tests/extensions/test_check_docs.py @@ -32,7 +32,11 @@ class TestParamDocChecker(CheckerTestCase): """Tests for pylint_plugin.ParamDocChecker""" CHECKER_CLASS = DocstringParameterChecker - CONFIG = {"accept_no_param_doc": False} + CONFIG = { + "accept_no_param_doc": False, + "no_docstring_rgx": "", + "docstring_min_length": -1, + } def test_missing_func_params_in_sphinx_docstring(self): """Example of a function with missing Sphinx parameter documentation in @@ -2296,3 +2300,37 @@ class TestParamDocChecker(CheckerTestCase): Message(msg_id="useless-type-doc", node=node, args=("_",)), ): self.checker.visit_functiondef(node) + + @set_config(no_docstring_rgx=r"^_(?!_).*$") + def test_skip_no_docstring_rgx(self): + """Example of a function that matches the default 'no-docstring-rgx' config option + + No error message is emitted. + """ + node = astroid.extract_node( + """ + def _private_function_foo(x, y): + '''docstring ... + + missing parameter documentation''' + pass + """ + ) + with self.assertNoMessages(): + self.checker.visit_functiondef(node) + + @set_config(docstring_min_length=3) + def test_skip_docstring_min_length(self): + """Example of a function that is less than 'docstring-min-length' config option + + No error message is emitted. + """ + node = astroid.extract_node( + """ + def function_foo(x, y): + '''function is too short and is missing parameter documentation''' + pass + """ + ) + with self.assertNoMessages(): + self.checker.visit_functiondef(node) |