2222from .tags import Tags
2323
2424
25+ def deprecated (method ):
26+ def wrapper (self , * args , ** kws ):
27+ """Deprecated."""
28+ if self .deprecate_keyword_attributes :
29+ warnings .warn (
30+ "'%s.%s' is deprecated." % (type (self ).__name__ , method .__name__ )
31+ )
32+ return method (self , * args , ** kws )
33+ return wrapper
34+
35+
2536@py3to2
2637@Body .register
2738class For (BodyItem ):
2839 type = BodyItem .FOR_TYPE
2940 body_class = Body
3041 repr_args = ('variables' , 'flavor' , 'values' )
3142 __slots__ = ['variables' , 'flavor' , 'values' ]
43+ deprecate_keyword_attributes = True
3244
3345 def __init__ (self , variables = (), flavor = 'IN' , values = (), parent = None ):
3446 self .variables = variables
@@ -65,42 +77,34 @@ def __str__(self):
6577 # TODO: Remove deprecated Keyword related properties in RF 4.1/5.0.
6678
6779 @property
80+ @deprecated
6881 def name (self ):
69- """Deprecated since Robot Framework 4.0."""
70- warnings .warn ("'For.name' is deprecated since Robot Framework 4.0. "
71- "Access 'variables', 'flavor' or 'values' directly or "
72- "use 'str()' to get a string representation." , UserWarning )
7382 return '%s %s [ %s ]' % (' | ' .join (self .variables ), self .flavor ,
7483 ' | ' .join (self .values ))
7584
7685 @property
86+ @deprecated
7787 def doc (self ):
78- """Deprecated since Robot Framework 4.0."""
79- warnings .warn ("'For.doc' is deprecated since Robot Framework 4.0." , UserWarning )
8088 return ''
8189
8290 @property
91+ @deprecated
8392 def args (self ):
84- """Deprecated since Robot Framework 4.0."""
85- warnings .warn ("'For.args' is deprecated since Robot Framework 4.0." , UserWarning )
8693 return ()
8794
8895 @property
96+ @deprecated
8997 def assign (self ):
90- """Deprecated since Robot Framework 4.0."""
91- warnings .warn ("'For.assign' is deprecated since Robot Framework 4.0." , UserWarning )
9298 return ()
9399
94100 @property
101+ @deprecated
95102 def tags (self ):
96- """Deprecated since Robot Framework 4.0."""
97- warnings .warn ("'For.tags' is deprecated since Robot Framework 4.0." , UserWarning )
98103 return Tags ()
99104
100105 @property
106+ @deprecated
101107 def timeout (self ):
102- """Deprecated since Robot Framework 4.0."""
103- warnings .warn ("'For.timeout' is deprecated since Robot Framework 4.0." , UserWarning )
104108 return None
105109
106110
@@ -111,6 +115,7 @@ class If(BodyItem):
111115 inactive = object ()
112116 repr_args = ('condition' ,)
113117 __slots__ = ['condition' , '_orelse' ]
118+ deprecate_keyword_attributes = True
114119
115120 def __init__ (self , condition = None , parent = None ):
116121 self .condition = condition
@@ -175,39 +180,31 @@ def __bool__(self):
175180 # TODO: Remove deprecated Keyword related properties in RF 4.1/5.0.
176181
177182 @property
183+ @deprecated
178184 def name (self ):
179- """Deprecated since Robot Framework 4.0."""
180- warnings .warn ("'If.name' is deprecated since Robot Framework 4.0. "
181- "Access 'condition' directly or use 'str()' to get "
182- "a string representation." , UserWarning )
183185 return self .condition
184186
185187 @property
188+ @deprecated
186189 def doc (self ):
187- """Deprecated since Robot Framework 4.0."""
188- warnings .warn ("'If.doc' is deprecated since Robot Framework 4.0." , UserWarning )
189190 return ''
190191
191192 @property
193+ @deprecated
192194 def args (self ):
193- """Deprecated since Robot Framework 4.0."""
194- warnings .warn ("'If.args' is deprecated since Robot Framework 4.0." , UserWarning )
195195 return ()
196196
197197 @property
198+ @deprecated
198199 def assign (self ):
199- """Deprecated since Robot Framework 4.0."""
200- warnings .warn ("'If.assign' is deprecated since Robot Framework 4.0." , UserWarning )
201200 return ()
202201
203202 @property
203+ @deprecated
204204 def tags (self ):
205- """Deprecated since Robot Framework 4.0."""
206- warnings .warn ("'If.tags' is deprecated since Robot Framework 4.0." , UserWarning )
207205 return Tags ()
208206
209207 @property
208+ @deprecated
210209 def timeout (self ):
211- """Deprecated since Robot Framework 4.0."""
212- warnings .warn ("'If.timeout' is deprecated since Robot Framework 4.0." , UserWarning )
213210 return None
0 commit comments