diff options
94 files changed, 433 insertions, 270 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index fb14047..5de9d3a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,10 @@ Changelog 0.5.1 (unreleased) ------------------ +* Test suite reorganized and enhanced in order to check more failures + with fewer test files. Read the ``run_tests`` docstring for details + about the syntax. + * Fix E225: accept ``print >>sys.stderr, "..."`` syntax. * Fix E501 for lines containing multibyte encoded characters. (Issue #7) @@ -818,13 +818,15 @@ class Checker(object): Load a Python source file, tokenize it, check coding style. """ - def __init__(self, filename): - if filename: - self.filename = filename + def __init__(self, filename, lines=None): + self.filename = filename + if filename is None: + self.filename = 'stdin' + self.lines = lines or [] + elif lines is None: self.lines = readlines(filename) else: - self.filename = 'stdin' - self.lines = [] + self.lines = lines options.counters['physical lines'] += len(self.lines) def readline(self): @@ -933,12 +935,14 @@ class Checker(object): text, check) self.previous_logical = self.logical_line - def check_all(self): + def check_all(self, expected=None, line_offset=0): """ Run all checks on the input file. """ - self.file_errors = 0 + self.expected = expected or () + self.line_offset = line_offset self.line_number = 0 + self.file_errors = 0 self.indent_char = None self.indent_level = 0 self.previous_logical = '' @@ -993,23 +997,19 @@ class Checker(object): return if options.quiet == 1 and not self.file_errors: message(self.filename) - self.file_errors += 1 if code in options.counters: options.counters[code] += 1 else: options.counters[code] = 1 options.messages[code] = text[5:] - if options.quiet: + if options.quiet or code in self.expected: + # Don't care about expected errors or warnings return - if options.testsuite: - basename = os.path.basename(self.filename) - if basename[:4] != code: - return # Don't care about other errors or warnings - if 'not' not in basename: - return # Don't print the expected error message + self.file_errors += 1 if options.counters[code] == 1 or options.repeat: message("%s:%s:%d: %s" % - (self.filename, line_number, offset + 1, text)) + (self.filename, self.line_offset + line_number, + offset + 1, text)) if options.show_source: line = self.lines[line_number - 1] message(line.rstrip()) @@ -1022,29 +1022,20 @@ def input_file(filename): """ Run all checks on a Python source file. """ - if excluded(filename): - return {} if options.verbose: message('checking ' + filename) - options.counters['files'] += 1 errors = Checker(filename).check_all() - if options.testsuite: # Check if the expected error was found - basename = os.path.basename(filename) - code = basename[:4] - count = options.counters.get(code, 0) - if count == 0 and 'not' not in basename: - message("%s: error %s not found" % (filename, code)) - # Keep showing errors for multiple tests - reset_counters() -def input_dir(dirname): +def input_dir(dirname, runner=None): """ Check all Python source files in this directory and all subdirectories. """ dirname = dirname.rstrip('/') if excluded(dirname): return + if runner is None: + runner = input_file for root, dirs, files in os.walk(dirname): if options.verbose: message('directory ' + root) @@ -1055,8 +1046,9 @@ def input_dir(dirname): dirs.remove(subdir) files.sort() for filename in files: - if filename_match(filename): - input_file(os.path.join(root, filename)) + if filename_match(filename) and not excluded(filename): + options.counters['files'] += 1 + runner(os.path.join(root, filename)) def excluded(filename): @@ -1158,6 +1150,56 @@ def print_benchmark(elapsed): options.counters[key])) +def run_tests(filename): + """ + Run all the tests from a file. + + A test file can provide many tests. Each test starts with a declaration. + This declaration is a single line starting with '#:'. + It declares codes of expected failures, separated by spaces or 'Okay' + if no failure is expected. + If the file does not contain such declaration, it should pass all tests. + If the declaration is empty, following lines are not checked, until next + declaration. + + Examples: + + * Only E224 and W701 are expected: #: E224 W701 + * Following example is conform: #: Okay + * Don't check these lines: #: + """ + lines = readlines(filename) + ['#:\n'] + line_offset = 0 + codes = ['Okay'] + testcase = [] + for index, line in enumerate(lines): + if not line.startswith('#:'): + if codes: + # Collect the lines of the test case + testcase.append(line) + continue + if codes and index > 0: + label = '%s:%s:1' % (filename, line_offset + 1) + codes = [c for c in codes if c != 'Okay'] + # Run the checker + errors = Checker(filename, testcase).check_all(codes, line_offset) + # Check if the expected errors were found + for code in codes: + if not options.counters.get(code): + errors += 1 + message('%s: error %s not found' % (label, code)) + if options.verbose and not errors: + message('%s: passed (%s)' % (label, ' '.join(codes))) + # Keep showing errors for multiple tests + reset_counters() + # output the real line numbers + line_offset = index + # configure the expected errors + codes = line.split()[1:] + # empty the test case buffer + del testcase[:] + + def selftest(): """ Test all check functions with test cases in docstrings. @@ -1291,12 +1333,17 @@ def _main(): import doctest doctest.testmod(verbose=options.verbose) selftest() + if options.testsuite: + runner = run_tests + else: + runner = input_file start_time = time.time() for path in args: if os.path.isdir(path): - input_dir(path) - else: - input_file(path) + input_dir(path, runner=runner) + elif not excluded(path): + options.counters['files'] += 1 + runner(path) elapsed = time.time() - start_time if options.statistics: print_statistics() diff --git a/testsuite/E101.py b/testsuite/E10.py index 6d1df2f..784b59a 100644 --- a/testsuite/E101.py +++ b/testsuite/E10.py @@ -1,3 +1,4 @@ +#: E101 W191 for a in 'abc': for b in 'xyz': print a # indented with 8 spaces diff --git a/testsuite/E11.py b/testsuite/E11.py new file mode 100644 index 0000000..8735e25 --- /dev/null +++ b/testsuite/E11.py @@ -0,0 +1,12 @@ +#: E111 +if x > 2: + print x +#: E111 +if True: + print +#: E112 +if False: +print +#: E113 +print + print diff --git a/testsuite/E111.py b/testsuite/E111.py deleted file mode 100644 index 7ac697b..0000000 --- a/testsuite/E111.py +++ /dev/null @@ -1,2 +0,0 @@ -if x > 2: - print x diff --git a/testsuite/E111b.py b/testsuite/E111b.py deleted file mode 100644 index 262f467..0000000 --- a/testsuite/E111b.py +++ /dev/null @@ -1,2 +0,0 @@ -if True: - print diff --git a/testsuite/E112.py b/testsuite/E112.py deleted file mode 100644 index 9aa3bc0..0000000 --- a/testsuite/E112.py +++ /dev/null @@ -1,2 +0,0 @@ -if False: -print diff --git a/testsuite/E113.py b/testsuite/E113.py deleted file mode 100644 index 5cb18ca..0000000 --- a/testsuite/E113.py +++ /dev/null @@ -1,2 +0,0 @@ -print - print diff --git a/testsuite/E20.py b/testsuite/E20.py new file mode 100644 index 0000000..5bdfea2 --- /dev/null +++ b/testsuite/E20.py @@ -0,0 +1,55 @@ +#: E201 +spam( ham[1], {eggs: 2}) +#: E201 +spam(ham[ 1], {eggs: 2}) +#: E201 +spam(ham[1], { eggs: 2}) +#: Okay +spam(ham[1], {eggs: 2}) +#: + + +#: E202 +spam(ham[1], {eggs: 2} ) +#: E202 +spam(ham[1], {eggs: 2 }) +#: E202 +spam(ham[1 ], {eggs: 2}) +#: Okay +spam(ham[1], {eggs: 2}) + +result = func( + arg1='some value', + arg2='another value', +) + +result = func( + arg1='some value', + arg2='another value' +) + +result = [ + item for item in items + if item > 5 +] +#: + + +#: E203 +if x == 4 : + print x, y + x, y = y, x +#: E203 E702 +if x == 4: + print x, y ; x, y = y, x +#: E203 +if x == 4: + print x, y + x, y = y , x +#: Okay +if x == 4: + print x, y + x, y = y, x +a[b1, :] == a[b1, ...] +b = a[:, b1] +#: diff --git a/testsuite/E201.py b/testsuite/E201.py deleted file mode 100644 index f60ae9c..0000000 --- a/testsuite/E201.py +++ /dev/null @@ -1 +0,0 @@ -spam( ham[1], {eggs: 2}) diff --git a/testsuite/E201b.py b/testsuite/E201b.py deleted file mode 100644 index e0415fe..0000000 --- a/testsuite/E201b.py +++ /dev/null @@ -1 +0,0 @@ -spam(ham[ 1], {eggs: 2}) diff --git a/testsuite/E201c.py b/testsuite/E201c.py deleted file mode 100644 index 715f3fc..0000000 --- a/testsuite/E201c.py +++ /dev/null @@ -1 +0,0 @@ -spam(ham[1], { eggs: 2}) diff --git a/testsuite/E201not.py b/testsuite/E201not.py deleted file mode 100644 index 3637e74..0000000 --- a/testsuite/E201not.py +++ /dev/null @@ -1 +0,0 @@ -spam(ham[1], {eggs: 2}) diff --git a/testsuite/E202.py b/testsuite/E202.py deleted file mode 100644 index 42b9ee4..0000000 --- a/testsuite/E202.py +++ /dev/null @@ -1 +0,0 @@ -spam(ham[1], {eggs: 2} ) diff --git a/testsuite/E202b.py b/testsuite/E202b.py deleted file mode 100644 index e72c3d4..0000000 --- a/testsuite/E202b.py +++ /dev/null @@ -1 +0,0 @@ -spam(ham[1], {eggs: 2 }) diff --git a/testsuite/E202c.py b/testsuite/E202c.py deleted file mode 100644 index b9c3782..0000000 --- a/testsuite/E202c.py +++ /dev/null @@ -1 +0,0 @@ -spam(ham[1 ], {eggs: 2}) diff --git a/testsuite/E202not.py b/testsuite/E202not.py deleted file mode 100644 index e152dcc..0000000 --- a/testsuite/E202not.py +++ /dev/null @@ -1,16 +0,0 @@ -spam(ham[1], {eggs: 2}) - -result = func( - arg1='some value', - arg2='another value', -) - -result = func( - arg1='some value', - arg2='another value' -) - -result = [ - item for item in items - if item > 5 -] diff --git a/testsuite/E203.py b/testsuite/E203.py deleted file mode 100644 index 7988201..0000000 --- a/testsuite/E203.py +++ /dev/null @@ -1 +0,0 @@ -if x == 4 : print x, y; x, y = y, x diff --git a/testsuite/E203b.py b/testsuite/E203b.py deleted file mode 100644 index 816c820..0000000 --- a/testsuite/E203b.py +++ /dev/null @@ -1 +0,0 @@ -if x == 4: print x, y ; x, y = y, x diff --git a/testsuite/E203c.py b/testsuite/E203c.py deleted file mode 100644 index aab0e18..0000000 --- a/testsuite/E203c.py +++ /dev/null @@ -1 +0,0 @@ -if x == 4: print x, y; x, y = y , x diff --git a/testsuite/E203not.py b/testsuite/E203not.py deleted file mode 100644 index 517aa8f..0000000 --- a/testsuite/E203not.py +++ /dev/null @@ -1,3 +0,0 @@ -if x == 4: print x, y; x, y = y, x -a[b1, :] == a[b1, ...] -b = a[:, b1] diff --git a/testsuite/E211not.py b/testsuite/E21.py index ae6bcfb..2280caf 100644 --- a/testsuite/E211not.py +++ b/testsuite/E21.py @@ -1,12 +1,17 @@ -spam(1) -dict['key'] = list[index] - - +#: E211 +spam (1) +#: E211 +dict ['key'] = list [index] +#: E211 +dict['key'] ['subkey'] = list[index] +#: E225 def squares(n): return (i**2 for i in range(n)) +#: Okay +spam(1) +dict['key'] = list[index] # This is not prohibited by PEP8, but avoid it. class Foo (Bar, Baz): pass - diff --git a/testsuite/E211.py b/testsuite/E211.py deleted file mode 100644 index 0318639..0000000 --- a/testsuite/E211.py +++ /dev/null @@ -1 +0,0 @@ -spam (1) diff --git a/testsuite/E211b.py b/testsuite/E211b.py deleted file mode 100644 index d4d1a2d..0000000 --- a/testsuite/E211b.py +++ /dev/null @@ -1 +0,0 @@ -dict ['key'] = list [index] diff --git a/testsuite/E211c.py b/testsuite/E211c.py deleted file mode 100644 index ffb7f7e..0000000 --- a/testsuite/E211c.py +++ /dev/null @@ -1 +0,0 @@ -dict['key'] ['subkey'] = list[index] diff --git a/testsuite/E22.py b/testsuite/E22.py new file mode 100644 index 0000000..e0cb8f9 --- /dev/null +++ b/testsuite/E22.py @@ -0,0 +1,87 @@ +#: E221 +a = 12 + 3 +b = 4 + 5 +#: E221 +x = 1 +y = 2 +long_variable = 3 +#: E221 +x[0] = 1 +x[1] = 2 +long_variable = 3 +#: E221 +x = f(x) + 1 +y = long_variable + 2 +z = x[0] + 3 +#: Okay +x = 1 +y = 2 +long_variable = 3 +#: + + +#: E222 +a = a + 1 +b = b + 10 +#: E222 +x = -1 +y = -2 +long_variable = 3 +#: E222 +x[0] = 1 +x[1] = 2 +long_variable = 3 +#: + + +#: E223 +foobart = 4 +a = 3 # aligned with tab +#: + + +#: E224 +a += 1 +b += 1000 +#: + + +#: E225 +i=i+1 +#: E225 +submitted +=1 +#: E225 +x = x*2 - 1 +#: E225 +hypot2 = x*x + y*y +#: E225 +c = (a+b) * (a-b) +#: E225 +c =-1 +#: E225 +c = alpha -4 +#: E225 +z = (x + 1) **y +#: E225 +norman = True+False +#: E225 +_1MB = 2 ** 20 +_1kB = _1MB >>10 +#: +#: Okay +i = i + 1 +submitted += 1 +x = x * 2 - 1 +hypot2 = x * x + y * y +c = (a + b) * (a - b) +foo(bar, key='word', *args, **kwargs) +baz(**kwargs) +negative = -1 +spam(-1) +-negative +lambda *args, **kw: (args, kw) +lambda a, b=h[:], c=0: (a, b, c) +if not -5 < x < +5: + print >>sys.stderr, "x is out of range." +print >> sys.stdout, "x is an integer." +#: diff --git a/testsuite/E221.py b/testsuite/E221.py deleted file mode 100644 index 0cb8a7e..0000000 --- a/testsuite/E221.py +++ /dev/null @@ -1,2 +0,0 @@ -a = 12 + 3 -b = 4 + 5 diff --git a/testsuite/E221b.py b/testsuite/E221b.py deleted file mode 100644 index ea240e2..0000000 --- a/testsuite/E221b.py +++ /dev/null @@ -1,3 +0,0 @@ -x = 1 -y = 2 -long_variable = 3 diff --git a/testsuite/E221c.py b/testsuite/E221c.py deleted file mode 100644 index 38e9da2..0000000 --- a/testsuite/E221c.py +++ /dev/null @@ -1,3 +0,0 @@ -x[0] = 1 -x[1] = 2 -long_variable = 3 diff --git a/testsuite/E221d.py b/testsuite/E221d.py deleted file mode 100644 index 2653835..0000000 --- a/testsuite/E221d.py +++ /dev/null @@ -1,3 +0,0 @@ -x = f(x) + 1 -y = long_variable + 2 -z = x[0] + 3 diff --git a/testsuite/E221not.py b/testsuite/E221not.py deleted file mode 100644 index 5d6d567..0000000 --- a/testsuite/E221not.py +++ /dev/null @@ -1,3 +0,0 @@ -x = 1 -y = 2 -long_variable = 3 diff --git a/testsuite/E222.py b/testsuite/E222.py deleted file mode 100644 index 0173196..0000000 --- a/testsuite/E222.py +++ /dev/null @@ -1,2 +0,0 @@ -a = a + 1 -b = b + 10 diff --git a/testsuite/E222b.py b/testsuite/E222b.py deleted file mode 100644 index 58ccbf3..0000000 --- a/testsuite/E222b.py +++ /dev/null @@ -1,3 +0,0 @@ -x = -1 -y = -2 -long_variable = 3 diff --git a/testsuite/E222c.py b/testsuite/E222c.py deleted file mode 100644 index 8e914ea..0000000 --- a/testsuite/E222c.py +++ /dev/null @@ -1,3 +0,0 @@ -x[0] = 1 -x[1] = 2 -long_variable = 3 diff --git a/testsuite/E223.py b/testsuite/E223.py deleted file mode 100644 index 6ef7456..0000000 --- a/testsuite/E223.py +++ /dev/null @@ -1,2 +0,0 @@ -foobart = 4 -a = 3 # aligned with tab diff --git a/testsuite/E224.py b/testsuite/E224.py deleted file mode 100644 index d8ada7f..0000000 --- a/testsuite/E224.py +++ /dev/null @@ -1,2 +0,0 @@ -a += 1 -b += 1000 diff --git a/testsuite/E225.py b/testsuite/E225.py deleted file mode 100644 index f3dbc45..0000000 --- a/testsuite/E225.py +++ /dev/null @@ -1 +0,0 @@ -i=i+1 diff --git a/testsuite/E225a.py b/testsuite/E225a.py deleted file mode 100644 index 3681ad2..0000000 --- a/testsuite/E225a.py +++ /dev/null @@ -1 +0,0 @@ -submitted +=1 diff --git a/testsuite/E225b.py b/testsuite/E225b.py deleted file mode 100644 index b6e0b52..0000000 --- a/testsuite/E225b.py +++ /dev/null @@ -1 +0,0 @@ -x = x*2 - 1 diff --git a/testsuite/E225c.py b/testsuite/E225c.py deleted file mode 100644 index 44e6f63..0000000 --- a/testsuite/E225c.py +++ /dev/null @@ -1 +0,0 @@ -hypot2 = x*x + y*y diff --git a/testsuite/E225d.py b/testsuite/E225d.py deleted file mode 100644 index 54da1a5..0000000 --- a/testsuite/E225d.py +++ /dev/null @@ -1 +0,0 @@ -c = (a+b) * (a-b) diff --git a/testsuite/E225e.py b/testsuite/E225e.py deleted file mode 100644 index f6a3686..0000000 --- a/testsuite/E225e.py +++ /dev/null @@ -1 +0,0 @@ -c =-1 diff --git a/testsuite/E225f.py b/testsuite/E225f.py deleted file mode 100644 index 439aa97..0000000 --- a/testsuite/E225f.py +++ /dev/null @@ -1 +0,0 @@ -c = alpha -4 diff --git a/testsuite/E225g.py b/testsuite/E225g.py deleted file mode 100644 index 55198f3..0000000 --- a/testsuite/E225g.py +++ /dev/null @@ -1 +0,0 @@ -z = (x + 1) **y diff --git a/testsuite/E225h.py b/testsuite/E225h.py deleted file mode 100644 index c30deb6..0000000 --- a/testsuite/E225h.py +++ /dev/null @@ -1 +0,0 @@ -norman = True+False diff --git a/testsuite/E225i.py b/testsuite/E225i.py deleted file mode 100644 index 6f51eb9..0000000 --- a/testsuite/E225i.py +++ /dev/null @@ -1,2 +0,0 @@ -_1MB = 2 ** 20 -_1kB = _1MB >>10 diff --git a/testsuite/E225not.py b/testsuite/E225not.py deleted file mode 100644 index 918ee8d..0000000 --- a/testsuite/E225not.py +++ /dev/null @@ -1,15 +0,0 @@ -i = i + 1 -submitted += 1 -x = x * 2 - 1 -hypot2 = x * x + y * y -c = (a + b) * (a - b) -foo(bar, key='word', *args, **kwargs) -baz(**kwargs) -negative = -1 -spam(-1) --negative -lambda *args, **kw: (args, kw) -lambda a, b=h[:], c=0: (a, b, c) -if not -5 < x < +5: - print >>sys.stderr, "x is out of range." -print >> sys.stdout, "x is an integer." diff --git a/testsuite/E231not.py b/testsuite/E23.py index 0d510bb..0f44f0c 100644 --- a/testsuite/E231not.py +++ b/testsuite/E23.py @@ -1,3 +1,8 @@ +#: E231 +a = (1,2) +#: E231 +a[b1,:] +#: Okay a = (4,) b = (5, ) @@ -5,4 +10,3 @@ result = { 'key1': 'value', 'key2': 'value', } - diff --git a/testsuite/E231.py b/testsuite/E231.py deleted file mode 100644 index 98b0a3d..0000000 --- a/testsuite/E231.py +++ /dev/null @@ -1 +0,0 @@ -a = (1,2) diff --git a/testsuite/E231b.py b/testsuite/E231b.py deleted file mode 100644 index f6da77c..0000000 --- a/testsuite/E231b.py +++ /dev/null @@ -1 +0,0 @@ -a[b1,:] diff --git a/testsuite/E242.py b/testsuite/E24.py index 40baaec..92ca515 100644 --- a/testsuite/E242.py +++ b/testsuite/E24.py @@ -1,2 +1,6 @@ +#: E241 +a = (1, 2) +b = (1, 20) +#: E242 a = (1, 2) # tab before 2 b = (1, 20) # space before 20 diff --git a/testsuite/E241.py b/testsuite/E241.py deleted file mode 100644 index 21ec72f..0000000 --- a/testsuite/E241.py +++ /dev/null @@ -1,2 +0,0 @@ -a = (1, 2) -b = (1, 20) diff --git a/testsuite/E25.py b/testsuite/E25.py new file mode 100644 index 0000000..ea9d638 --- /dev/null +++ b/testsuite/E25.py @@ -0,0 +1,15 @@ +#: E251 +def foo(bar = False): + '''Test function with an error in declaration''' + pass +#: E251 +foo(bar= True) +#: E251 +foo(bar =True) +#: E251 +foo(bar = True) +#: Okay +foo(bar=(1 == 1)) +foo(bar=(1 != 1)) +foo(bar=(1 >= 1)) +foo(bar=(1 <= 1)) diff --git a/testsuite/E251.py b/testsuite/E251.py deleted file mode 100644 index e7c1843..0000000 --- a/testsuite/E251.py +++ /dev/null @@ -1,3 +0,0 @@ -def foo(bar = False): - '''Test function with an error in declaration''' - pass diff --git a/testsuite/E251b.py b/testsuite/E251b.py deleted file mode 100644 index 0d424b4..0000000 --- a/testsuite/E251b.py +++ /dev/null @@ -1 +0,0 @@ -foo(bar= True) diff --git a/testsuite/E251c.py b/testsuite/E251c.py deleted file mode 100644 index eb81c22..0000000 --- a/testsuite/E251c.py +++ /dev/null @@ -1 +0,0 @@ -foo(bar =True) diff --git a/testsuite/E251d.py b/testsuite/E251d.py deleted file mode 100644 index 90d8668..0000000 --- a/testsuite/E251d.py +++ /dev/null @@ -1 +0,0 @@ -foo(bar = True) diff --git a/testsuite/E251not.py b/testsuite/E251not.py deleted file mode 100644 index 0e4213c..0000000 --- a/testsuite/E251not.py +++ /dev/null @@ -1,5 +0,0 @@ -# These are not errors -foo(bar=(1 == 1)) -foo(bar=(1 != 1)) -foo(bar=(1 >= 1)) -foo(bar=(1 <= 1)) diff --git a/testsuite/E26.py b/testsuite/E26.py new file mode 100644 index 0000000..b4f7af7 --- /dev/null +++ b/testsuite/E26.py @@ -0,0 +1,6 @@ +#: E261 +pass # an inline comment +#: E262 +x = x + 1 #Increment x +#: E262 +x = x + 1 # Increment x diff --git a/testsuite/E261.py b/testsuite/E261.py deleted file mode 100644 index 4d87729..0000000 --- a/testsuite/E261.py +++ /dev/null @@ -1 +0,0 @@ -pass # an inline comment diff --git a/testsuite/E262.py b/testsuite/E262.py deleted file mode 100644 index 7402e10..0000000 --- a/testsuite/E262.py +++ /dev/null @@ -1 +0,0 @@ -x = x + 1 #Increment x diff --git a/testsuite/E262b.py b/testsuite/E262b.py deleted file mode 100644 index b7ecc32..0000000 --- a/testsuite/E262b.py +++ /dev/null @@ -1 +0,0 @@ -x = x + 1 # Increment x diff --git a/testsuite/E30.py b/testsuite/E30.py new file mode 100644 index 0000000..e2d6271 --- /dev/null +++ b/testsuite/E30.py @@ -0,0 +1,66 @@ +#: E301 +class X: + + def a(): + pass + def b(): + pass +#: E301 +class X: + + def a(): + pass + # comment + def b(): + pass +#: + + +#: E302 +def a(): + pass + +def b(): + pass +#: E302 +def a(): + pass + +# comment + +def b(): + pass +#: + + +#: E303 +print + + + +print +#: E303 +print + + + +# comment + +print +#: E303 +def a(): + print + + + # comment + + print +#: + + +#: E304 +@decorator + +def function(): + pass +#: diff --git a/testsuite/E301.py b/testsuite/E301.py deleted file mode 100644 index f77fabe..0000000 --- a/testsuite/E301.py +++ /dev/null @@ -1,6 +0,0 @@ -class X: - - def a(): - pass - def b(): - pass diff --git a/testsuite/E301b.py b/testsuite/E301b.py deleted file mode 100644 index fee3301..0000000 --- a/testsuite/E301b.py +++ /dev/null @@ -1,7 +0,0 @@ -class X: - - def a(): - pass - # comment - def b(): - pass diff --git a/testsuite/E302.py b/testsuite/E302.py deleted file mode 100644 index ccf4703..0000000 --- a/testsuite/E302.py +++ /dev/null @@ -1,5 +0,0 @@ -def a(): - pass - -def b(): - pass diff --git a/testsuite/E302b.py b/testsuite/E302b.py deleted file mode 100644 index f468dde..0000000 --- a/testsuite/E302b.py +++ /dev/null @@ -1,7 +0,0 @@ -def a(): - pass - -# comment - -def b(): - pass diff --git a/testsuite/E302not.py b/testsuite/E302not.py deleted file mode 100644 index 548d551..0000000 --- a/testsuite/E302not.py +++ /dev/null @@ -1,36 +0,0 @@ -def a(): - pass - - -class Foo(): - """Class Foo""" - - def b(): - - pass - - -# comment -def c(): - pass - - -# comment - - -def d(): - pass - -# This is a -# ... multi-line comment - -# And this one is -# ... a second paragraph -# ... which spans on 3 lines - - -# Function `e` is below -# NOTE: Hey this is a testcase - -def e(): - pass diff --git a/testsuite/E303.py b/testsuite/E303.py deleted file mode 100644 index 99e8ce2..0000000 --- a/testsuite/E303.py +++ /dev/null @@ -1,5 +0,0 @@ -print - - - -print diff --git a/testsuite/E303b.py b/testsuite/E303b.py deleted file mode 100644 index 3b24e3e..0000000 --- a/testsuite/E303b.py +++ /dev/null @@ -1,7 +0,0 @@ -print - - - -# comment - -print diff --git a/testsuite/E303c.py b/testsuite/E303c.py deleted file mode 100644 index 7b9754c..0000000 --- a/testsuite/E303c.py +++ /dev/null @@ -1,7 +0,0 @@ -def a(): - print - - - # comment - - print diff --git a/testsuite/E303not.py b/testsuite/E303not.py deleted file mode 100644 index 7387dbd..0000000 --- a/testsuite/E303not.py +++ /dev/null @@ -1,19 +0,0 @@ -def a(): - print - - # comment - - print - - print - -# Comment 1 - -# Comment 2 - - -# Comment 3 - -def b(): - - pass diff --git a/testsuite/E304.py b/testsuite/E304.py deleted file mode 100644 index 5edba99..0000000 --- a/testsuite/E304.py +++ /dev/null @@ -1,4 +0,0 @@ -@decorator - -def function(): - pass diff --git a/testsuite/E301not.py b/testsuite/E30not.py index da32dd3..8538fd7 100644 --- a/testsuite/E301not.py +++ b/testsuite/E30not.py @@ -57,3 +57,62 @@ except NameError: for item in iterator: return item return default + + +def a(): + pass + + +class Foo(): + """Class Foo""" + + def b(): + + pass + + +# comment +def c(): + pass + + +# comment + + +def d(): + pass + +# This is a +# ... multi-line comment + +# And this one is +# ... a second paragraph +# ... which spans on 3 lines + + +# Function `e` is below +# NOTE: Hey this is a testcase + +def e(): + pass + + +def a(): + print + + # comment + + print + + print + +# Comment 1 + +# Comment 2 + + +# Comment 3 + +def b(): + + pass diff --git a/testsuite/E401not.py b/testsuite/E40.py index 856c1b1..d921c25 100644 --- a/testsuite/E401not.py +++ b/testsuite/E40.py @@ -1,3 +1,6 @@ +#: E401 +import os, sys +#: Okay import os import sys diff --git a/testsuite/E401.py b/testsuite/E401.py deleted file mode 100644 index e652432..0000000 --- a/testsuite/E401.py +++ /dev/null @@ -1 +0,0 @@ -import os, sys diff --git a/testsuite/E501.py b/testsuite/E50.py index 4cdc757..1c26e4f 100644 --- a/testsuite/E501.py +++ b/testsuite/E50.py @@ -1 +1,2 @@ +#: E501 a = '12345678901234567890123456789012345678901234567890123456789012345678901234567890' diff --git a/testsuite/E70.py b/testsuite/E70.py new file mode 100644 index 0000000..e0a9a7d --- /dev/null +++ b/testsuite/E70.py @@ -0,0 +1,4 @@ +#: E701 +if a: a = False +#: E702 +a = False; b = True diff --git a/testsuite/E701.py b/testsuite/E701.py deleted file mode 100644 index 77273e7..0000000 --- a/testsuite/E701.py +++ /dev/null @@ -1 +0,0 @@ -if a: a = False diff --git a/testsuite/E702.py b/testsuite/E702.py deleted file mode 100644 index 9cb8415..0000000 --- a/testsuite/E702.py +++ /dev/null @@ -1 +0,0 @@ -a = False; b = True diff --git a/testsuite/W191.py b/testsuite/W19.py index 81cca0b..a629abe 100644 --- a/testsuite/W191.py +++ b/testsuite/W19.py @@ -1,2 +1,3 @@ +#: W191 if False: print # indented with 1 tab diff --git a/testsuite/W29.py b/testsuite/W29.py new file mode 100644 index 0000000..85f1137 --- /dev/null +++ b/testsuite/W29.py @@ -0,0 +1,8 @@ +#: W291 +print +#: W293 +class Foo(object): + + bang = 12 +#: W292 +# This line doesn't have a linefeed
\ No newline at end of file diff --git a/testsuite/W291.py b/testsuite/W291.py deleted file mode 100644 index 004cfa9..0000000 --- a/testsuite/W291.py +++ /dev/null @@ -1 +0,0 @@ -print diff --git a/testsuite/W291not.py b/testsuite/W291not.py deleted file mode 100644 index 10fd47a..0000000 --- a/testsuite/W291not.py +++ /dev/null @@ -1,3 +0,0 @@ -class Foo(object): - - bang = 12 diff --git a/testsuite/W292.py b/testsuite/W292.py deleted file mode 100644 index bf3205e..0000000 --- a/testsuite/W292.py +++ /dev/null @@ -1 +0,0 @@ -# This line doesn't have a linefeed
\ No newline at end of file diff --git a/testsuite/W293.py b/testsuite/W293.py deleted file mode 100644 index 10fd47a..0000000 --- a/testsuite/W293.py +++ /dev/null @@ -1,3 +0,0 @@ -class Foo(object): - - bang = 12 diff --git a/testsuite/W391.py b/testsuite/W39.py index 0975d3a..4fe4fc4 100644 --- a/testsuite/W391.py +++ b/testsuite/W39.py @@ -1,2 +1,3 @@ +#: W391 # The next line is blank diff --git a/testsuite/W60.py b/testsuite/W60.py new file mode 100644 index 0000000..19b6549 --- /dev/null +++ b/testsuite/W60.py @@ -0,0 +1,10 @@ +#: W601 +if a.has_key("b"): + print a +#: W602 +raise DummyError, "Message" +#: W603 +if x <> 0: + x = 0 +#: W604 +val = `1 + 2` diff --git a/testsuite/W601.py b/testsuite/W601.py deleted file mode 100644 index 466ba63..0000000 --- a/testsuite/W601.py +++ /dev/null @@ -1,2 +0,0 @@ -if a.has_key("b"): - print a diff --git a/testsuite/W602.py b/testsuite/W602.py deleted file mode 100644 index d64883d..0000000 --- a/testsuite/W602.py +++ /dev/null @@ -1 +0,0 @@ -raise DummyError, "Message" diff --git a/testsuite/W603.py b/testsuite/W603.py deleted file mode 100644 index 5dd9b7d..0000000 --- a/testsuite/W603.py +++ /dev/null @@ -1,2 +0,0 @@ -if x <> 0: - x = 0 diff --git a/testsuite/W604.py b/testsuite/W604.py deleted file mode 100644 index bfe92b9..0000000 --- a/testsuite/W604.py +++ /dev/null @@ -1 +0,0 @@ -val = `1 + 2` diff --git a/testsuite/E113not.py b/testsuite/latin-1.py index adc0007..8328cfb 100644 --- a/testsuite/E113not.py +++ b/testsuite/latin-1.py @@ -1,5 +1,5 @@ # -*- coding: latin-1 -*- -# Test non-UTF8 encoding, along with E113 +# Test non-UTF8 encoding latin1 = ('ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ' 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ') diff --git a/testsuite/E501not.py b/testsuite/utf-8.py index 46bdb2d..46bdb2d 100644 --- a/testsuite/E501not.py +++ b/testsuite/utf-8.py |