Print name of violating file in unittest

Include the name of the file that violates the unittest name check in
the error message so that it's easy to track down the problem. Also,
exclude emacs autosave files from the list.

Change-Id: Ib6a8557ee2bc2262fb0235c5641bd9da70f66fe0
This commit is contained in:
Monty Taylor 2017-05-04 18:20:50 -04:00
parent 7bfc3f3706
commit 1c6fa5b335
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
1 changed files with 6 additions and 2 deletions

View File

@ -88,8 +88,12 @@ class TestTitles(testtools.TestCase):
def test_template(self):
files = glob.glob("guidelines/*")
for file in files:
self.assertTrue(file.endswith(".rst") or file.endswith(".json"),
"guideline files must use 'rst' or 'json' extension.")
if file.endswith('~'):
continue
self.assertTrue(
file.endswith(".rst") or file.endswith(".json"),
"guideline file must use 'rst' or 'json'"
"extension: {file}".format(file=file))
with open(file) as f:
data = f.read()