summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/decorators.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/utils/decorators.py')
-rw-r--r--meta/lib/oeqa/utils/decorators.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index d52f326f1a..0b23565485 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -115,6 +115,8 @@ class NoParsingFilter(logging.Filter):
115 def filter(self, record): 115 def filter(self, record):
116 return record.levelno == 100 116 return record.levelno == 100
117 117
118import inspect
119
118def LogResults(original_class): 120def LogResults(original_class):
119 orig_method = original_class.run 121 orig_method = original_class.run
120 122
@@ -124,6 +126,19 @@ def LogResults(original_class):
124 logfile = os.path.join(os.getcwd(),'results-'+caller+'.'+timestamp+'.log') 126 logfile = os.path.join(os.getcwd(),'results-'+caller+'.'+timestamp+'.log')
125 linkfile = os.path.join(os.getcwd(),'results-'+caller+'.log') 127 linkfile = os.path.join(os.getcwd(),'results-'+caller+'.log')
126 128
129 def get_class_that_defined_method(meth):
130 if inspect.ismethod(meth):
131 for cls in inspect.getmro(meth.__self__.__class__):
132 if cls.__dict__.get(meth.__name__) is meth:
133 return cls
134 meth = meth.__func__ # fallback to __qualname__ parsing
135 if inspect.isfunction(meth):
136 cls = getattr(inspect.getmodule(meth),
137 meth.__qualname__.split('.<locals>', 1)[0].rsplit('.', 1)[0])
138 if isinstance(cls, type):
139 return cls
140 return None
141
127 #rewrite the run method of unittest.TestCase to add testcase logging 142 #rewrite the run method of unittest.TestCase to add testcase logging
128 def run(self, result, *args, **kws): 143 def run(self, result, *args, **kws):
129 orig_method(self, result, *args, **kws) 144 orig_method(self, result, *args, **kws)
@@ -135,7 +150,7 @@ def LogResults(original_class):
135 except AttributeError: 150 except AttributeError:
136 test_case = self._testMethodName 151 test_case = self._testMethodName
137 152
138 class_name = str(testMethod.im_class).split("'")[1] 153 class_name = str(get_class_that_defined_method(testMethod)).split("'")[1]
139 154
140 #create custom logging level for filtering. 155 #create custom logging level for filtering.
141 custom_log_level = 100 156 custom_log_level = 100
@@ -215,7 +230,7 @@ def tag(*args, **kwargs):
215 def wrap_ob(ob): 230 def wrap_ob(ob):
216 for name in args: 231 for name in args:
217 setattr(ob, __tag_prefix + name, True) 232 setattr(ob, __tag_prefix + name, True)
218 for name, value in kwargs.iteritems(): 233 for name, value in kwargs.items():
219 setattr(ob, __tag_prefix + name, value) 234 setattr(ob, __tag_prefix + name, value)
220 return ob 235 return ob
221 return wrap_ob 236 return wrap_ob