diff options
author | Aaron Meurer <asmeurer@gmail.com> | 2014-02-22 14:46:24 -0600 |
---|---|---|
committer | Aaron Meurer <asmeurer@gmail.com> | 2014-02-22 14:46:24 -0600 |
commit | 32fb6d7280c653e9bb67f4080481327744339042 (patch) | |
tree | fcf92536dc38f622c54e18063e529b789f482fd2 | |
parent | e0f746ae819700db37770cb351f91aa20c81db47 (diff) | |
download | pyflakes-32fb6d7280c653e9bb67f4080481327744339042.tar.gz |
Reported column offset should be vim-style. Fix all tests.
-rw-r--r-- | pyflakes/reporter.py | 2 | ||||
-rw-r--r-- | pyflakes/test/test_api.py | 20 |
2 files changed, 11 insertions, 11 deletions
diff --git a/pyflakes/reporter.py b/pyflakes/reporter.py index a4b6840..4b8d31e 100644 --- a/pyflakes/reporter.py +++ b/pyflakes/reporter.py @@ -54,7 +54,7 @@ class Reporter(object): line = text.splitlines()[-1] if offset is not None: offset = offset - (len(text) - len(line)) - self._stderr.write('%s:%d:%d: %s\n' % (filename, lineno, offset, + self._stderr.write('%s:%d:%d: %s\n' % (filename, lineno, offset + 1, msg)) else: self._stderr.write('%s:%d: %s\n' % (filename, lineno, msg)) diff --git a/pyflakes/test/test_api.py b/pyflakes/test/test_api.py index 2fac879..1d58d80 100644 --- a/pyflakes/test/test_api.py +++ b/pyflakes/test/test_api.py @@ -161,9 +161,9 @@ class TestReporter(TestCase): reporter = Reporter(None, err) reporter.syntaxError('foo.py', 'a problem', 3, 7, 'bad line of source') self.assertEqual( - ("foo.py:3:7: a problem\n" + ("foo.py:3:8: a problem\n" "bad line of source\n" - " ^\n"), + " ^\n"), err.getvalue()) def test_syntaxErrorNoOffset(self): @@ -195,9 +195,9 @@ class TestReporter(TestCase): reporter.syntaxError('foo.py', 'a problem', 3, len(lines[0]) + 7, '\n'.join(lines)) self.assertEqual( - ("foo.py:3:6: a problem\n" + + ("foo.py:3:7: a problem\n" + lines[-1] + "\n" + - " ^\n"), + " ^\n"), err.getvalue()) def test_unexpectedError(self): @@ -320,7 +320,7 @@ def baz(): self.assertHasErrors( sourcePath, ["""\ -%s:8:10: invalid syntax +%s:8:11: invalid syntax '''quux''' ^ """ % (sourcePath,)]) @@ -334,7 +334,7 @@ def baz(): self.assertHasErrors( sourcePath, ["""\ -%s:1:8: unexpected EOF while parsing +%s:1:9: unexpected EOF while parsing def foo( ^ """ % (sourcePath,)]) @@ -348,7 +348,7 @@ def foo( self.assertHasErrors( sourcePath, ["""\ -%s:2: invalid syntax +%s:2:7: invalid syntax \tfoo = \t ^ """ % (sourcePath,)]) @@ -365,7 +365,7 @@ def foo(bar=baz, bax): """ sourcePath = self.makeTempFile(source) last_line = ' ^\n' if sys.version_info >= (3, 2) else '' - column = '7:' if sys.version_info >= (3, 2) else '' + column = '8:' if sys.version_info >= (3, 2) else '' self.assertHasErrors( sourcePath, ["""\ @@ -384,7 +384,7 @@ foo(bar=baz, bax) """ sourcePath = self.makeTempFile(source) last_line = ' ^\n' if sys.version_info >= (3, 2) else '' - column = '12:' if sys.version_info >= (3, 2) else '' + column = '13:' if sys.version_info >= (3, 2) else '' self.assertHasErrors( sourcePath, ["""\ @@ -406,7 +406,7 @@ foo(bar=baz, bax) # Column has been "fixed" since 3.2.4 and 3.3.1 col = 1 if ver >= (3, 3, 1) or ((3, 2, 4) <= ver < (3, 3)) else 2 decoding_error = """\ -%s:1:6: (unicode error) 'unicodeescape' codec can't decode bytes \ +%s:1:7: (unicode error) 'unicodeescape' codec can't decode bytes \ in position 0-%d: truncated \\xXX escape foo = '\\xyz' %s""" % (sourcePath, col, last_line) |