def test_syntaxErrorNoOffset(self): """ C{syntaxError} doesn't include a caret pointing to the error if C{offset} is passed as C{None}. """ err = StringIO() reporter = Reporter(None, err) reporter.syntaxError("foo.py", "a problem", 3, None, "bad line of source") self.assertEqual(("foo.py:3: a problem\n" "bad line of source\n"), err.getvalue())
def test_syntaxErrorNoOffset(self): """ C{syntaxError} doesn't include a caret pointing to the error if C{offset} is passed as C{None}. """ err = StringIO() reporter = Reporter(None, err) reporter.syntaxError('foo.py', 'a problem', 3, None, 'bad line of source') self.assertEquals(("foo.py:3: a problem\n" "bad line of source\n"), err.getvalue())
def test_multiLineSyntaxError(self): """ If there's a multi-line syntax error, then we only report the last line. The offset is adjusted so that it is relative to the start of the last line. """ err = StringIO() lines = ["bad line of source", "more bad lines of source"] reporter = Reporter(None, err) reporter.syntaxError("foo.py", "a problem", 3, len(lines[0]) + 7, "\n".join(lines)) self.assertEqual(("foo.py:3:7: a problem\n" + lines[-1] + "\n" + " ^\n"), err.getvalue())
def test_syntaxError(self): """ C{syntaxError} reports that there was a syntax error in the source file. It reports to the error stream and includes the filename, line number, error message, actual line of source and a caret pointing to where the error is. """ err = StringIO() reporter = Reporter(None, err) reporter.syntaxError("foo.py", "a problem", 3, 7, "bad line of source") self.assertEqual(("foo.py:3:8: a problem\n" "bad line of source\n" " ^\n"), err.getvalue())
def test_syntaxError(self): """ C{syntaxError} reports that there was a syntax error in the source file. It reports to the error stream and includes the filename, line number, error message, actual line of source and a caret pointing to where the error is. """ err = StringIO() reporter = Reporter(None, err) reporter.syntaxError('foo.py', 'a problem', 3, 4, 'bad line of source') self.assertEquals(("foo.py:3: a problem\n" "bad line of source\n" " ^\n"), err.getvalue())
def test_multiLineSyntaxError(self): """ If there's a multi-line syntax error, then we only report the last line. The offset is adjusted so that it is relative to the start of the last line. """ err = StringIO() lines = ["bad line of source", "more bad lines of source"] reporter = Reporter(None, err) reporter.syntaxError("foo.py", "a problem", 3, len(lines[0]) + 7, "\n".join(lines)) self.assertEqual( ("foo.py:3:7: a problem\n" + lines[-1] + "\n" + " ^\n"), err.getvalue(), )
def test_multiLineSyntaxError(self): """ If there's a multi-line syntax error, then we only report the last line. The offset is adjusted so that it is relative to the start of the last line. """ err = StringIO() lines = [ 'bad line of source', 'more bad lines of source', ] reporter = Reporter(None, err) reporter.syntaxError('foo.py', 'a problem', 3, len(lines[0]) + 7, '\n'.join(lines)) column = 25 if sys.version_info >= (3, 8) else 7 self.assertEqual( ("foo.py:3:%d: a problem\n" % column + lines[-1] + "\n" + " " * (column - 1) + "^\n"), err.getvalue())
def test_syntaxError(self): """ C{syntaxError} reports that there was a syntax error in the source file. It reports to the error stream and includes the filename, line number, error message, actual line of source and a caret pointing to where the error is. """ err = StringIO() reporter = Reporter(None, err) reporter.syntaxError( "foo.py", "a problem", 3, 8 if sys.version_info >= (3, 8) else 7, "bad line of source", ) self.assertEqual( ("foo.py:3:8: a problem\n" "bad line of source\n" " ^\n"), err.getvalue(), )
"""