File tree Expand file tree Collapse file tree
python/ql/test/library-tests/descriptors Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- | 55 | classmethod() | 56 | Function c1 |
2- | 62 | classmethod() | 59 | Function c2 |
3- | 63 | classmethod() | 59 | Function c2 |
4- | 65 | staticmethod() | 66 | Function s1 |
5- | 72 | staticmethod() | 69 | Function s2 |
6- | 73 | staticmethod() | 69 | Function s2 |
1+ | 104 | classmethod() | 105 | Function c1 |
2+ | 111 | classmethod() | 108 | Function c2 |
3+ | 112 | classmethod() | 108 | Function c2 |
4+ | 114 | staticmethod() | 115 | Function s1 |
5+ | 121 | staticmethod() | 118 | Function s2 |
6+ | 122 | staticmethod() | 118 | Function s2 |
Original file line number Diff line number Diff line change @@ -43,13 +43,62 @@ def getx(self):
4343
4444 x = property (getx )
4545
46+ class WithoutDecoratorOnlyGetterKWArg (object ):
47+
48+ def getx (self ):
49+ return 42
50+
51+ x = property (fget = getx )
52+
4653class WithoutDecoratorOnlySetter (object ):
4754
4855 def setx (self , value ):
4956 self ._x = value
5057
5158 x = property (fset = setx ) # TODO: Not handled
5259
60+ class WithDecoratorOnlySetter (object ):
61+
62+ x = property ()
63+
64+ @x .setter
65+ def x (self , value ):
66+ print ('{} setting value to {}' .format (self .__class__ , value ))
67+
68+ class FunkyButValid (object ):
69+
70+ def delx (self ):
71+ print ("deleting x" )
72+
73+ x = property (fdel = delx )
74+
75+ @x .setter
76+ def y (self , value ):
77+ print ('setting value to {}' .format (value ))
78+
79+ @y .getter
80+ def z (self ):
81+ return 42
82+
83+
84+ wat = FunkyButValid ()
85+ try :
86+ wat .x
87+ except AttributeError as e :
88+ print ("x can't be read" )
89+ del wat .x
90+
91+ try :
92+ wat .y
93+ except AttributeError as e :
94+ print ("y can't be read" )
95+ wat .y = 1234
96+ del wat .y
97+
98+ print (wat .z )
99+ wat .z = 10
100+ del wat .z
101+
53102class D (object ):
54103
55104 @classmethod
You can’t perform that action at this time.
0 commit comments