changeset 2283:959d0815e149

pep8: don't count stuff we ignore, added comments about pep8 test usage
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 02 Jul 2007 19:33:45 +0200
parents bb9853b194f7
children 71f7bde1077b
files MoinMoin/_tests/pep8.py MoinMoin/_tests/test_sourcecode.py
diffstat 2 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/pep8.py	Mon Jul 02 19:07:39 2007 +0200
+++ b/MoinMoin/_tests/pep8.py	Mon Jul 02 19:33:45 2007 +0200
@@ -642,8 +642,10 @@
         """
         if options.quiet == 1 and not self.file_errors:
             message(self.filename)
+        code = text[:4]
+        if ignore_code(code):
+            return
         self.file_errors += 1
-        code = text[:4]
         options.counters[code] = options.counters.get(code, 0) + 1
         options.messages[code] = text[5:]
         if options.quiet:
@@ -654,8 +656,6 @@
                 return
             if base[0] == 'E' and code[0] == 'W':
                 return
-        if ignore_code(code):
-            return
         if options.counters[code] == 1 or options.repeat:
             message("%s:%s:%d: %s" %
                     (self.filename, line_number, offset + 1, text))
--- a/MoinMoin/_tests/test_sourcecode.py	Mon Jul 02 19:07:39 2007 +0200
+++ b/MoinMoin/_tests/test_sourcecode.py	Mon Jul 02 19:33:45 2007 +0200
@@ -26,7 +26,7 @@
                            # use 'fix' with extreme caution and in a separate changeset!
 FIX_TS_RE = re.compile(r' +$', re.M) # 'fix' mode: everything matching the trailing space re will be removed
 
-PEP8_CHECKS = False
+PEP8_CHECKS = True
 
 def test_sourcecode():
     def walk(reldir):
@@ -53,7 +53,9 @@
                         f.write(data)
                         f.close()
                 if PEP8_CHECKS:
-                    assert pep8_checker(path) == 0
+                    # Please read and follow PEP8 - rerun this test until it does not fail any more,
+                    # any type of error is only reported ONCE (even if there are multiple).
+                    assert pep8_error_count(path) == 0
         elif os.path.isdir(path):
             for entry in os.listdir(path):
                 if not entry.startswith('.'):
@@ -63,9 +65,11 @@
     EXCLUDE = dict([(path, True) for path in EXCLUDE]) # dict lookup is faster
     walk('')
 
-def pep8_checker(path):
-    import pep8
-    #pep8.process_options(['pep8', '--ignore=E401,E501,W', path])
-    pep8.process_options(['pep8', path])
+import pep8
+pep8.process_options(['pep8', '--ignore=E302,E401,E501,E701,W', 'dummy_path'])
+#pep8.process_options(['pep8', path])
+
+def pep8_error_count(path):
     error_count = pep8.Checker(path).check_all()
     return error_count
+