mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-07 21:34:32 +08:00
Remove support for parsing Python 2
This commit is contained in:
@@ -26,7 +26,7 @@ class TestsFunctionAndLambdaParsing(object):
|
||||
|
||||
@pytest.fixture(params=FIXTURES)
|
||||
def node(self, request):
|
||||
parsed = parse(dedent(request.param[0]), version='3.5')
|
||||
parsed = parse(dedent(request.param[0]), version='3.10')
|
||||
request.keywords['expected'] = request.param[1]
|
||||
child = parsed.children[0]
|
||||
if child.type == 'simple_stmt':
|
||||
@@ -79,16 +79,16 @@ def test_default_param(each_version):
|
||||
assert not param.star_count
|
||||
|
||||
|
||||
def test_annotation_param(each_py3_version):
|
||||
func = parse('def x(foo: 3): pass', version=each_py3_version).children[0]
|
||||
def test_annotation_param(each_version):
|
||||
func = parse('def x(foo: 3): pass', version=each_version).children[0]
|
||||
param, = func.get_params()
|
||||
assert param.default is None
|
||||
assert param.annotation.value == '3'
|
||||
assert not param.star_count
|
||||
|
||||
|
||||
def test_annotation_params(each_py3_version):
|
||||
func = parse('def x(foo: 3, bar: 4): pass', version=each_py3_version).children[0]
|
||||
def test_annotation_params(each_version):
|
||||
func = parse('def x(foo: 3, bar: 4): pass', version=each_version).children[0]
|
||||
param1, param2 = func.get_params()
|
||||
|
||||
assert param1.default is None
|
||||
@@ -100,23 +100,14 @@ def test_annotation_params(each_py3_version):
|
||||
assert not param2.star_count
|
||||
|
||||
|
||||
def test_default_and_annotation_param(each_py3_version):
|
||||
func = parse('def x(foo:3=42): pass', version=each_py3_version).children[0]
|
||||
def test_default_and_annotation_param(each_version):
|
||||
func = parse('def x(foo:3=42): pass', version=each_version).children[0]
|
||||
param, = func.get_params()
|
||||
assert param.default.value == '42'
|
||||
assert param.annotation.value == '3'
|
||||
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]
|
||||
subscript = trailer.children[1]
|
||||
assert subscript.type == 'subscript'
|
||||
assert [leaf.value for leaf in subscript.children] == ['.', '.', '.']
|
||||
|
||||
|
||||
def get_yield_exprs(code, version):
|
||||
return list(parse(code, version=version).children[0].iter_yield_exprs())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user