mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
method decorator tests
This commit is contained in:
@@ -76,7 +76,7 @@ exe[4]['d']
|
||||
|
||||
|
||||
# -----------------
|
||||
# class decorators
|
||||
# Decorator is a class
|
||||
# -----------------
|
||||
class Decorator(object):
|
||||
def __init__(self, func):
|
||||
@@ -122,6 +122,39 @@ JustAClass.a.
|
||||
#? []
|
||||
JustAClass().a()
|
||||
|
||||
# -----------------
|
||||
# method decorators
|
||||
# -----------------
|
||||
|
||||
def dec(f):
|
||||
def wrapper(s):
|
||||
return f(s)
|
||||
return wrapper
|
||||
|
||||
class MethodDecorators():
|
||||
_class_var = 1
|
||||
def __init__(self):
|
||||
self._method_var = ''
|
||||
|
||||
@dec
|
||||
def constant(self):
|
||||
return 1.0
|
||||
|
||||
@dec
|
||||
def class_var(self):
|
||||
return self._class_var
|
||||
|
||||
@dec
|
||||
def method_var(self):
|
||||
return self._method_var
|
||||
|
||||
#? float()
|
||||
MethodDecorators().constant()
|
||||
#? int()
|
||||
MethodDecorators().class_var()
|
||||
#? str()
|
||||
MethodDecorators().method_var()
|
||||
|
||||
# -----------------
|
||||
# others
|
||||
# -----------------
|
||||
|
||||
Reference in New Issue
Block a user