mirror of
https://github.com/davidhalter/parso.git
synced 2026-02-05 17:38:03 +08:00
Use ERROR_DEDENT instead of ERRORTOKEN for wrong dedents.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
for a in 'abc':
|
||||
for b in 'xyz':
|
||||
hello(a) # indented with 8 spaces
|
||||
#: E901:1
|
||||
#: E903:0
|
||||
hello(b) # indented with 1 tab
|
||||
if True:
|
||||
#: E101:0
|
||||
|
||||
@@ -112,7 +112,6 @@ def test_ellipsis_py2(each_py2_version):
|
||||
module = parse('[0][...]', version=each_py2_version, error_recovery=False)
|
||||
expr = module.children[0]
|
||||
trailer = expr.children[-1]
|
||||
print(expr)
|
||||
subscript = trailer.children[1]
|
||||
assert subscript.type == 'subscript'
|
||||
assert [leaf.value for leaf in subscript.children] == ['.', '.', '.']
|
||||
|
||||
@@ -45,6 +45,7 @@ def test_syntax_errors(code, positions):
|
||||
@pytest.mark.parametrize(
|
||||
('code', 'positions'), [
|
||||
(' 1', [(1, 0)]),
|
||||
('def x():\n 1\n 2', [(3, 0)]),
|
||||
]
|
||||
)
|
||||
def test_indentation_errors(code, positions):
|
||||
|
||||
@@ -7,7 +7,7 @@ import pytest
|
||||
from parso._compatibility import py_version
|
||||
from parso.utils import splitlines, parse_version_string
|
||||
from parso.python.token import (
|
||||
NAME, NEWLINE, STRING, INDENT, DEDENT, ERRORTOKEN, ENDMARKER)
|
||||
NAME, NEWLINE, STRING, INDENT, DEDENT, ERRORTOKEN, ENDMARKER, ERROR_DEDENT)
|
||||
from parso.python import tokenize
|
||||
from parso import parse
|
||||
from parso.python.tokenize import TokenInfo
|
||||
@@ -212,23 +212,12 @@ def test_endmarker_end_pos():
|
||||
check('a\\')
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('code', 'types'), [
|
||||
(' foo', ['error_leaf', 'name'])
|
||||
]
|
||||
)
|
||||
def test_indentation(code, types):
|
||||
return
|
||||
actual_types = [t.type for t in _get_token_list(code)]
|
||||
print(actual_types)
|
||||
assert False
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('code', 'types'), [
|
||||
(' foo', [INDENT, NAME, DEDENT]),
|
||||
(' foo\n bar', [INDENT, NAME, NEWLINE, ERRORTOKEN, NAME, DEDENT]),
|
||||
(' foo\n bar \n baz', [INDENT, NAME, NEWLINE, ERRORTOKEN, NAME,
|
||||
NEWLINE, ERRORTOKEN, NAME, DEDENT]),
|
||||
(' foo\n bar', [INDENT, NAME, NEWLINE, ERROR_DEDENT, NAME, DEDENT]),
|
||||
(' foo\n bar \n baz', [INDENT, NAME, NEWLINE, ERROR_DEDENT, NAME,
|
||||
NEWLINE, ERROR_DEDENT, NAME, DEDENT]),
|
||||
(' foo\nbar', [INDENT, NAME, NEWLINE, DEDENT, NAME]),
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user