pylint: stop requiring docstrings on TestCase methods
Most TestCase docstrings are redundant. A test name should clearly
indicate what the test does and expects, since that's all one gets in
case of failures. Thus, docstrings end up just repeating what the name
already tells us.
BUG=None
TEST=`./utils/run_pylint.py client/bin/local_host_unittest.py` no longer
complains about missing method docstrings.
Change-Id: Ieb0fa1456ee26a73d13462ccf939ef91e3417a7d
Reviewed-on: https://chromium-review.googlesource.com/571186
Commit-Ready: Prathmesh Prabhu <[email protected]>
Tested-by: Prathmesh Prabhu <[email protected]>
Reviewed-by: Prathmesh Prabhu <[email protected]>
diff --git a/utils/run_pylint.py b/utils/run_pylint.py
index 6bf52ec..08efb83 100755
--- a/utils/run_pylint.py
+++ b/utils/run_pylint.py
@@ -180,6 +180,9 @@
node.parent.frame().ancestors())):
return
+ if _is_test_case_method(node):
+ return
+
super(CustomDocStringChecker, self).visit_function(node)
@@ -397,6 +400,21 @@
tempdir.clean()
+def _is_test_case_method(node):
+ """Determine if the given function node is a method of a TestCase.
+
+ We simply check for 'TestCase' being one of the parent classes in the mro of
+ the containing class.
+
+ @params node: A function node.
+ """
+ if not hasattr(node.parent.frame(), 'ancestors'):
+ return False
+
+ parent_class_names = {x.name for x in node.parent.frame().ancestors()}
+ return 'TestCase' in parent_class_names
+
+
def main():
"""Main function checks each file in a commit for pylint violations."""