forked from VimPlug/jedi
Add SyntaxError.get_message
This commit is contained in:
@@ -9,6 +9,7 @@ Unreleased: 0.17.1 (2020-04-)
|
|||||||
- Django ``Model`` meta class support
|
- Django ``Model`` meta class support
|
||||||
- Added Django Stubs to Jedi, thanks to all contributors of the
|
- Added Django Stubs to Jedi, thanks to all contributors of the
|
||||||
`Django Stubs <https://github.com/typeddjango/django-stubs>`_ project
|
`Django Stubs <https://github.com/typeddjango/django-stubs>`_ project
|
||||||
|
- Added ``SyntaxError.get_message``
|
||||||
- Python 3.9 support
|
- Python 3.9 support
|
||||||
- A few bugfixes
|
- A few bugfixes
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ class SyntaxError(object):
|
|||||||
"""The column where the error ends (starting with 0)."""
|
"""The column where the error ends (starting with 0)."""
|
||||||
return self._parso_error.end_pos[1]
|
return self._parso_error.end_pos[1]
|
||||||
|
|
||||||
|
def get_message(self):
|
||||||
|
return self._parso_error.message
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s from=%s to=%s>' % (
|
return '<%s from=%s to=%s>' % (
|
||||||
self.__class__.__name__,
|
self.__class__.__name__,
|
||||||
|
|||||||
@@ -10,20 +10,21 @@ import pytest
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'code, line, column, until_line, until_column', [
|
'code, line, column, until_line, until_column, message', [
|
||||||
('?\n', 1, 0, 1, 1),
|
('?\n', 1, 0, 1, 1, 'SyntaxError: invalid syntax'),
|
||||||
('x %% y', 1, 3, 1, 4),
|
('x %% y', 1, 3, 1, 4, 'SyntaxError: invalid syntax'),
|
||||||
('"""\n\n', 1, 0, 3, 0),
|
('"""\n\n', 1, 0, 3, 0, 'SyntaxError: EOF while scanning triple-quoted string literal'),
|
||||||
('(1, 2\n', 2, 0, 2, 0),
|
('(1, 2\n', 2, 0, 2, 0, 'SyntaxError: invalid syntax'),
|
||||||
('foo(1, 2\ndef x(): pass', 2, 0, 2, 3),
|
('foo(1, 2\ndef x(): pass', 2, 0, 2, 3, 'SyntaxError: invalid syntax'),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_simple_syntax_errors(Script, code, line, column, until_line, until_column):
|
def test_simple_syntax_errors(Script, code, line, column, until_line, until_column, message):
|
||||||
e, = Script(code).get_syntax_errors()
|
e, = Script(code).get_syntax_errors()
|
||||||
assert e.line == line
|
assert e.line == line
|
||||||
assert e.column == column
|
assert e.column == column
|
||||||
assert e.until_line == until_line
|
assert e.until_line == until_line
|
||||||
assert e.until_column == until_column
|
assert e.until_column == until_column
|
||||||
|
assert e.get_message() == message
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|||||||
Reference in New Issue
Block a user