mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-08 05:34:51 +08:00
Make ellipsis work for the differences between 2 and 3.
This commit is contained in:
@@ -159,7 +159,12 @@ def _create_token_collection(version_int):
|
|||||||
r"~")
|
r"~")
|
||||||
|
|
||||||
Bracket = '[][(){}]'
|
Bracket = '[][(){}]'
|
||||||
Special = group(r'\r?\n', r'\.\.\.', r'[:;.,@]')
|
|
||||||
|
special_args = [r'\r?\n', r'[:;.,@]']
|
||||||
|
if version_int >= 30:
|
||||||
|
special_args.insert(0, r'\.\.\.')
|
||||||
|
Special = group(*special_args)
|
||||||
|
|
||||||
Funny = group(Operator, Bracket, Special)
|
Funny = group(Operator, Bracket, Special)
|
||||||
|
|
||||||
# First (or only) line of ' or " string.
|
# First (or only) line of ' or " string.
|
||||||
|
|||||||
@@ -106,3 +106,13 @@ def test_default_and_annotation_param(each_py3_version):
|
|||||||
assert param.default.value == '42'
|
assert param.default.value == '42'
|
||||||
assert param.annotation.value == '3'
|
assert param.annotation.value == '3'
|
||||||
assert not param.star_count
|
assert not param.star_count
|
||||||
|
|
||||||
|
|
||||||
|
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] == ['.', '.', '.']
|
||||||
|
|||||||
@@ -285,6 +285,11 @@ def test_multiline_bytes_tripquote_literals(each_version):
|
|||||||
_parse(s, each_version)
|
_parse(s, each_version)
|
||||||
|
|
||||||
|
|
||||||
|
def test_ellipsis(works_ge_py3, each_version):
|
||||||
|
works_ge_py3.parse("...")
|
||||||
|
_parse("[0][...]", version=each_version)
|
||||||
|
|
||||||
|
|
||||||
def test_multiline_str_literals(each_version):
|
def test_multiline_str_literals(each_version):
|
||||||
s = """
|
s = """
|
||||||
md5test("\xaa" * 80,
|
md5test("\xaa" * 80,
|
||||||
|
|||||||
Reference in New Issue
Block a user