summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/decorators.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index b9fc76c9ee..769b4fffdd 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -185,4 +185,36 @@ def timeout(seconds):
185 return wrapped_f 185 return wrapped_f
186 else: 186 else:
187 return fn 187 return fn
188 return decorator \ No newline at end of file 188 return decorator
189
190__tag_prefix = "tag__"
191def tag(*args, **kwargs):
192 """Decorator that adds attributes to classes or functions
193 for use with the Attribute (-a) plugin.
194 """
195 def wrap_ob(ob):
196 for name in args:
197 setattr(ob, __tag_prefix + name, True)
198 for name, value in kwargs.iteritems():
199 setattr(ob, __tag_prefix + name, value)
200 return ob
201 return wrap_ob
202
203def gettag(obj, key, default=None):
204 key = __tag_prefix + key
205 if not isinstance(obj, unittest.TestCase):
206 return getattr(obj, key, default)
207 tc_method = getattr(obj, obj._testMethodName)
208 ret = getattr(tc_method, key, getattr(obj, key, default))
209 return ret
210
211def getAllTags(obj):
212 def __gettags(o):
213 r = {k[len(__tag_prefix):]:getattr(o,k) for k in dir(o) if k.startswith(__tag_prefix)}
214 return r
215 if not isinstance(obj, unittest.TestCase):
216 return __gettags(obj)
217 tc_method = getattr(obj, obj._testMethodName)
218 ret = __gettags(obj)
219 ret.update(__gettags(tc_method))
220 return ret