1
0
forked from VimPlug/jedi

Python 2 allows tuple unpacking in parameter definitions. Jedi just ignores such constructs, since they are really rare and not the future.

This commit is contained in:
Dave Halter
2015-03-24 15:02:07 +01:00
parent 61683cb83e
commit 0de5a0f412
2 changed files with 51 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import sys
import jedi
from jedi._compatibility import u, is_py3
@@ -180,3 +181,24 @@ def test_end_pos_error_correction():
# at all. We just want to make sure that the module end_pos is correct!
assert func.end_pos == (3, 0)
assert m.end_pos == (2, 2)
def test_param_splitting():
"""
Jedi splits parameters into params, this is not what the grammar does,
but Jedi does this to simplify argument parsing.
"""
def check(src, result):
# Python 2 tuple params should be ignored for now.
grammar = load_grammar('grammar%s.%s' % sys.version_info[:2])
m = Parser(grammar, u(src)).module
if is_py3:
assert not m.subscopes
else:
# We don't want b and c to be a part of the param enumeration. Just
# ignore them, because it's not what we want to support in the
# future.
assert [str(param.name) for param in m.subscopes[0].params] == result
check('def x(a, (b, c)):\n pass', ['a'])
check('def x((b, c)):\n pass', [])