From 56a14c7811b08cc7422dee060ea0a650c8ebe2af Mon Sep 17 00:00:00 2001 From: David Halter Date: Wed, 27 Jun 2012 10:24:31 +0200 Subject: [PATCH] move decorator tests --- evaluate.py | 2 ++ test/completion/classes.py | 46 ------------------------ test/completion/decorators.py | 68 +++++++++++++++++++++++++++++++++++ test/completion/functions.py | 49 ------------------------- 4 files changed, 70 insertions(+), 95 deletions(-) diff --git a/evaluate.py b/evaluate.py index 8dcf39eb..022968e3 100644 --- a/evaluate.py +++ b/evaluate.py @@ -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) diff --git a/test/completion/classes.py b/test/completion/classes.py index 22aa9f87..d2979537 100644 --- a/test/completion/classes.py +++ b/test/completion/classes.py @@ -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 # ----------------- diff --git a/test/completion/decorators.py b/test/completion/decorators.py index f7ee4540..8af008bf 100644 --- a/test/completion/decorators.py +++ b/test/completion/decorators.py @@ -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 # ----------------- diff --git a/test/completion/functions.py b/test/completion/functions.py index f7fa56d5..e3c96f3b 100644 --- a/test/completion/functions.py +++ b/test/completion/functions.py @@ -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 # -----------------