add hacking.py rule to prevent docstrings
add new rule for hacking.py to catch and prevent docstrings on
test_ functions in the tempest/test directory. Found 2 oddballs
that I missed on the last conversion.
update ./run_tests.sh to not ingore all N4* errors (basically all
our custom rules), 401 and 402 still ignored because we actually
have a lot of errors on both of those.
Change-Id: I894d181433b7dcd1a9f4429f1a463be75018f05e
diff --git a/tools/hacking.py b/tools/hacking.py
index 6e66005..58e56c4 100755
--- a/tools/hacking.py
+++ b/tools/hacking.py
@@ -290,7 +290,7 @@
end = max([physical_line[-4:-1] == i for i in DOCSTRING_TRIPLE]) # end
if (pos != -1 and end and len(physical_line) > pos + 4):
if (physical_line[-5] != '.'):
- return pos, "TEMPEST N402: one line docstring needs a period"
+ return pos, "N402: one line docstring needs a period"
def tempest_docstring_multiline_end(physical_line):
@@ -306,6 +306,23 @@
return (pos, "TEMPEST N403: multi line docstring end on new line")
+def tempest_no_test_docstring(physical_line, previous_logical, filename):
+ """Check that test_ functions don't have docstrings
+
+ This ensure we get better results out of tempest, instead
+ of them being hidden behind generic descriptions of the
+ functions.
+
+ N404
+ """
+ if "tempest/test" in filename:
+ pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE])
+ if pos != -1:
+ if previous_logical.startswith("def test_"):
+ return (pos, "TEMPEST N404: test functions must "
+ "not have doc strings")
+
+
FORMAT_RE = re.compile("%(?:"
"%|" # Ignore plain percents
"(\(\w+\))?" # mapping key