A test suite imported from jedi.

This commit is contained in:
Dave Halter
2017-05-11 09:43:37 -04:00
parent 6caedbdb68
commit 7445c303e3
12 changed files with 1798 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
'''
To make the life of any analysis easier, we are generating Param objects
instead of simple parser objects.
'''
from textwrap import dedent
from parso.python import parse
def assert_params(param_string, **wanted_dct):
source = dedent('''
def x(%s):
pass
''') % param_string
module = parse(source)
funcdef = next(module.iter_funcdefs())
dct = dict((p.name.value, p.default and p.default.get_code())
for p in funcdef.params)
assert dct == wanted_dct
assert module.get_code() == source
def test_split_params_with_separation_star():
assert_params(u'x, y=1, *, z=3', x=None, y='1', z='3')
assert_params(u'*, x', x=None)
assert_params(u'*')
def test_split_params_with_stars():
assert_params(u'x, *args', x=None, args=None)
assert_params(u'**kwargs', kwargs=None)
assert_params(u'*args, **kwargs', args=None, kwargs=None)