summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/decorators.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-20 11:57:44 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-02 08:24:01 +0100
commit3b3997174831931ea472167ba6cc854a4972ccce (patch)
tree861b0bcb54e70fbe59bf7920862954dcec40a1e8 /meta/lib/oeqa/utils/decorators.py
parent52c4b7f247618f185a11dfb1cf15d0490d074379 (diff)
downloadpoky-3b3997174831931ea472167ba6cc854a4972ccce.tar.gz
classes/lib: Complete transition to python3
This patch contains all the other misc pieces of the transition to python3 which didn't make sense to be broken into individual patches. (From OE-Core rev: fcd6b38bab8517d83e1ed48eef1bca9a9a190f57) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils/decorators.py')
-rw-r--r--meta/lib/oeqa/utils/decorators.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index 6fb09db417..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