mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-10 15:51:51 +08:00
move decorator tests
This commit is contained in:
@@ -1049,6 +1049,8 @@ def follow_call_list(scope, call_list):
|
||||
# The string tokens are just operations (+, -, etc.)
|
||||
elif not isinstance(call, str):
|
||||
# ternary operators
|
||||
#if str(call.name) == 'for':
|
||||
# print '\n\ndini mueter'
|
||||
if str(call.name) == 'if':
|
||||
while True:
|
||||
call = next(calls_iterator)
|
||||
|
||||
@@ -151,31 +151,6 @@ CallClass()()
|
||||
# properties
|
||||
# -----------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class B():
|
||||
@property
|
||||
def r(self):
|
||||
@@ -197,27 +172,6 @@ B().p
|
||||
##? []
|
||||
B().p()
|
||||
|
||||
property2 = property
|
||||
|
||||
# -----------------
|
||||
# class decorators
|
||||
# -----------------
|
||||
class Decorator(object):
|
||||
def __init__(self, func):
|
||||
self.func = func
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self.func(1, *args, **kwargs)
|
||||
|
||||
@Decorator
|
||||
def nothing(a,b,c):
|
||||
return a,b,c
|
||||
|
||||
#? int()
|
||||
nothing("")[0]
|
||||
#? str()
|
||||
nothing("")[1]
|
||||
|
||||
# -----------------
|
||||
# variable assignments
|
||||
# -----------------
|
||||
|
||||
@@ -1,3 +1,71 @@
|
||||
# -----------------
|
||||
# normal decorators
|
||||
# -----------------
|
||||
|
||||
def decorator(func):
|
||||
def wrapper(*args):
|
||||
return func(1, *args)
|
||||
return wrapper
|
||||
|
||||
@decorator
|
||||
def decorated(a,b):
|
||||
return a,b
|
||||
|
||||
exe = decorated(set, '')
|
||||
|
||||
#? set
|
||||
exe[1]
|
||||
|
||||
#? int()
|
||||
exe[0]
|
||||
|
||||
# more complicated with args/kwargs
|
||||
def dec(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
@dec
|
||||
def fu(a, b, c, *args, **kwargs):
|
||||
return a, b, c, args, kwargs
|
||||
|
||||
exe = fu(list, c=set, b=3, d='')
|
||||
|
||||
#? ['append']
|
||||
exe[0].append
|
||||
#? ['real']
|
||||
exe[1].real
|
||||
#? ['union']
|
||||
exe[2].union
|
||||
|
||||
#? str()
|
||||
exe[4]['d']
|
||||
|
||||
|
||||
exe = fu(list, set, 3, '', d='')
|
||||
|
||||
#? str()
|
||||
exe[3][0]
|
||||
|
||||
# -----------------
|
||||
# class decorators
|
||||
# -----------------
|
||||
class Decorator(object):
|
||||
def __init__(self, func):
|
||||
self.func = func
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self.func(1, *args, **kwargs)
|
||||
|
||||
@Decorator
|
||||
def nothing(a,b,c):
|
||||
return a,b,c
|
||||
|
||||
#? int()
|
||||
nothing("")[0]
|
||||
#? str()
|
||||
nothing("")[1]
|
||||
|
||||
# -----------------
|
||||
# not found decorators
|
||||
# -----------------
|
||||
|
||||
@@ -173,55 +173,6 @@ exe[3].items
|
||||
#? set()
|
||||
exe[3]['c']
|
||||
|
||||
# -----------------
|
||||
# decorators
|
||||
# -----------------
|
||||
|
||||
def decorator(func):
|
||||
def wrapper(*args):
|
||||
return func(1, *args)
|
||||
return wrapper
|
||||
|
||||
@decorator
|
||||
def decorated(a,b):
|
||||
return a,b
|
||||
|
||||
exe = decorated(set, '')
|
||||
|
||||
#? set
|
||||
exe[1]
|
||||
|
||||
#? int()
|
||||
exe[0]
|
||||
|
||||
# more complicated with args/kwargs
|
||||
def dec(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
@dec
|
||||
def fu(a, b, c, *args, **kwargs):
|
||||
return a, b, c, args, kwargs
|
||||
|
||||
exe = fu(list, c=set, b=3, d='')
|
||||
|
||||
#? ['append']
|
||||
exe[0].append
|
||||
#? ['real']
|
||||
exe[1].real
|
||||
#? ['union']
|
||||
exe[2].union
|
||||
|
||||
#? str()
|
||||
exe[4]['d']
|
||||
|
||||
|
||||
exe = fu(list, set, 3, '', d='')
|
||||
|
||||
#? str()
|
||||
exe[3][0]
|
||||
|
||||
# -----------------
|
||||
# generators
|
||||
# -----------------
|
||||
|
||||
Reference in New Issue
Block a user