summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2012-09-27 09:30:26 -0700
committerJelmer Vernooij <jelmer@samba.org>2012-09-27 18:45:12 +0200
commit6986f7bdda56d693c642945485006f9660053758 (patch)
treed28d0d64cf59b88e14b828b21fc6c8e7c8010728 /source4/scripting/python
parentf8aab2f55fb552c6fd1fc51106cc237f9a1fc32a (diff)
downloadsamba-6986f7bdda56d693c642945485006f9660053758.tar.gz
samba-6986f7bdda56d693c642945485006f9660053758.tar.bz2
samba-6986f7bdda56d693c642945485006f9660053758.zip
samba.tests.source: Check for trailing whitespace in Python files.
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/samba/tests/source.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/source4/scripting/python/samba/tests/source.py b/source4/scripting/python/samba/tests/source.py
index 0876b043d0..2612ae68cf 100644
--- a/source4/scripting/python/samba/tests/source.py
+++ b/source4/scripting/python/samba/tests/source.py
@@ -183,6 +183,16 @@ class TestSource(TestCase):
self.fail(self._format_message(illegal_newlines,
'Non-unix newlines were found in the following source files:'))
+ def test_trailing_whitespace(self):
+ """Check that there is not trailing whitespace in Python files."""
+ trailing_whitespace = {}
+ for fname, line_no, line in self._iter_source_files_lines():
+ if line.rstrip("\n").endswith(" "):
+ self._push_file(trailing_whitespace, fname, line_no)
+ if trailing_whitespace:
+ self.fail(self._format_message(trailing_whitespace,
+ 'Trailing whitespace was found in the following source files.'))
+
def test_shebang_lines(self):
"""Check that files with shebang lines and only those are executable."""
files_with_shebang = {}
@@ -246,4 +256,9 @@ class TestSource(TestCase):
checker.report_error = report_error
checker.check_all()
if len(pep8_errors) > 0:
- self.fail('there were %d pep8 errors' % len(pep8_errors))
+ d = {}
+ for (fname, line_no, offset, text, check) in pep8_errors:
+ d.setdefault(fname, []).append(line_no - 1)
+ self.fail(self._format_message(d,
+ 'There were %d PEP8 errors:' % len(pep8_errors)))
+