mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-07 21:34:32 +08:00
Fix python 2 tests
This commit is contained in:
@@ -11,16 +11,19 @@ def test_with_stmt():
|
|||||||
assert module.children[2].type == 'name'
|
assert module.children[2].type == 'name'
|
||||||
|
|
||||||
|
|
||||||
def test_one_line_function():
|
def test_one_line_function(each_version):
|
||||||
module = parse('def x(): f.')
|
module = parse('def x(): f.', version=each_version)
|
||||||
assert module.children[0].type == 'funcdef'
|
assert module.children[0].type == 'funcdef'
|
||||||
def_, name, parameters, colon, f = module.children[0].children
|
def_, name, parameters, colon, f = module.children[0].children
|
||||||
assert f.type == 'error_node'
|
assert f.type == 'error_node'
|
||||||
|
|
||||||
module = parse('def x(a:')
|
module = parse('def x(a:', version=each_version)
|
||||||
func = module.children[0]
|
func = module.children[0]
|
||||||
assert func.type == 'error_node'
|
assert func.type == 'error_node'
|
||||||
assert func.children[-1] == ':'
|
if each_version.startswith('2'):
|
||||||
|
assert func.children[-1].value == 'a'
|
||||||
|
else:
|
||||||
|
assert func.children[-1] == ':'
|
||||||
|
|
||||||
|
|
||||||
def test_if_stmt():
|
def test_if_stmt():
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ STRING = PythonTokenTypes.STRING
|
|||||||
INDENT = PythonTokenTypes.INDENT
|
INDENT = PythonTokenTypes.INDENT
|
||||||
DEDENT = PythonTokenTypes.DEDENT
|
DEDENT = PythonTokenTypes.DEDENT
|
||||||
ERRORTOKEN = PythonTokenTypes.ERRORTOKEN
|
ERRORTOKEN = PythonTokenTypes.ERRORTOKEN
|
||||||
|
OP = PythonTokenTypes.OP
|
||||||
ENDMARKER = PythonTokenTypes.ENDMARKER
|
ENDMARKER = PythonTokenTypes.ENDMARKER
|
||||||
ERROR_DEDENT = PythonTokenTypes.ERROR_DEDENT
|
ERROR_DEDENT = PythonTokenTypes.ERROR_DEDENT
|
||||||
FSTRING_START = PythonTokenTypes.FSTRING_START
|
FSTRING_START = PythonTokenTypes.FSTRING_START
|
||||||
@@ -137,7 +138,7 @@ def test_identifier_contains_unicode():
|
|||||||
else:
|
else:
|
||||||
# Unicode tokens in Python 2 seem to be identified as operators.
|
# Unicode tokens in Python 2 seem to be identified as operators.
|
||||||
# They will be ignored in the parser, that's ok.
|
# They will be ignored in the parser, that's ok.
|
||||||
assert unicode_token[0] == ERRORTOKEN
|
assert unicode_token[0] == OP
|
||||||
|
|
||||||
|
|
||||||
def test_quoted_strings():
|
def test_quoted_strings():
|
||||||
|
|||||||
Reference in New Issue
Block a user