summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/decorators.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2014-12-23 14:34:29 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-12-25 08:27:12 +0000
commitd4d73b0139d7cdd490b0e7d783c9bab61446f995 (patch)
tree05270973b9284d88933421b55904f7767b4917e2 /meta/lib/oeqa/utils/decorators.py
parente75139cc9d5a6a8ecd58bd854cd9ced77ea1d046 (diff)
downloadpoky-d4d73b0139d7cdd490b0e7d783c9bab61446f995.tar.gz
oeqa/utils: replace some tabs with spaces
Python code should use spaces only for indentation. (From OE-Core rev: a1e22121e521aabf454a850cd7c8be60b7b1adc3) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> 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.py84
1 files changed, 42 insertions, 42 deletions
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index 7f845dbb4b..1ae1162e33 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -86,14 +86,14 @@ class testcase(object):
86 self.test_case = test_case 86 self.test_case = test_case
87 87
88 def __call__(self, func): 88 def __call__(self, func):
89 def wrapped_f(*args): 89 def wrapped_f(*args):
90 return func(*args) 90 return func(*args)
91 wrapped_f.test_case = self.test_case 91 wrapped_f.test_case = self.test_case
92 return wrapped_f 92 return wrapped_f
93 93
94class NoParsingFilter(logging.Filter): 94class NoParsingFilter(logging.Filter):
95 def filter(self, record): 95 def filter(self, record):
96 return record.levelno == 100 96 return record.levelno == 100
97 97
98def LogResults(original_class): 98def LogResults(original_class):
99 orig_method = original_class.run 99 orig_method = original_class.run
@@ -101,51 +101,51 @@ def LogResults(original_class):
101 #rewrite the run method of unittest.TestCase to add testcase logging 101 #rewrite the run method of unittest.TestCase to add testcase logging
102 def run(self, result, *args, **kws): 102 def run(self, result, *args, **kws):
103 orig_method(self, result, *args, **kws) 103 orig_method(self, result, *args, **kws)
104 passed = True 104 passed = True
105 testMethod = getattr(self, self._testMethodName) 105 testMethod = getattr(self, self._testMethodName)
106 106
107 #if test case is decorated then use it's number, else use it's name 107 #if test case is decorated then use it's number, else use it's name
108 try: 108 try:
109 test_case = testMethod.test_case 109 test_case = testMethod.test_case
110 except AttributeError: 110 except AttributeError:
111 test_case = self._testMethodName 111 test_case = self._testMethodName
112 112
113 #create custom logging level for filtering. 113 #create custom logging level for filtering.
114 custom_log_level = 100 114 custom_log_level = 100
115 logging.addLevelName(custom_log_level, 'RESULTS') 115 logging.addLevelName(custom_log_level, 'RESULTS')
116 caller = os.path.basename(sys.argv[0]) 116 caller = os.path.basename(sys.argv[0])
117 117
118 def results(self, message, *args, **kws): 118 def results(self, message, *args, **kws):
119 if self.isEnabledFor(custom_log_level): 119 if self.isEnabledFor(custom_log_level):
120 self.log(custom_log_level, message, *args, **kws) 120 self.log(custom_log_level, message, *args, **kws)
121 logging.Logger.results = results 121 logging.Logger.results = results
122 122
123 logging.basicConfig(filename=os.path.join(os.getcwd(),'results-'+caller+'.log'), 123 logging.basicConfig(filename=os.path.join(os.getcwd(),'results-'+caller+'.log'),
124 filemode='w', 124 filemode='w',
125 format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', 125 format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
126 datefmt='%H:%M:%S', 126 datefmt='%H:%M:%S',
127 level=custom_log_level) 127 level=custom_log_level)
128 for handler in logging.root.handlers: 128 for handler in logging.root.handlers:
129 handler.addFilter(NoParsingFilter()) 129 handler.addFilter(NoParsingFilter())
130 local_log = logging.getLogger(caller) 130 local_log = logging.getLogger(caller)
131 131
132 #check status of tests and record it 132 #check status of tests and record it
133 for (name, msg) in result.errors: 133 for (name, msg) in result.errors:
134 if self._testMethodName == str(name).split(' ')[0]: 134 if self._testMethodName == str(name).split(' ')[0]:
135 local_log.results("Testcase "+str(test_case)+": ERROR") 135 local_log.results("Testcase "+str(test_case)+": ERROR")
136 local_log.results("Testcase "+str(test_case)+":\n"+msg) 136 local_log.results("Testcase "+str(test_case)+":\n"+msg)
137 passed = False 137 passed = False
138 for (name, msg) in result.failures: 138 for (name, msg) in result.failures:
139 if self._testMethodName == str(name).split(' ')[0]: 139 if self._testMethodName == str(name).split(' ')[0]:
140 local_log.results("Testcase "+str(test_case)+": FAILED") 140 local_log.results("Testcase "+str(test_case)+": FAILED")
141 local_log.results("Testcase "+str(test_case)+":\n"+msg) 141 local_log.results("Testcase "+str(test_case)+":\n"+msg)
142 passed = False 142 passed = False
143 for (name, msg) in result.skipped: 143 for (name, msg) in result.skipped:
144 if self._testMethodName == str(name).split(' ')[0]: 144 if self._testMethodName == str(name).split(' ')[0]:
145 local_log.results("Testcase "+str(test_case)+": SKIPPED") 145 local_log.results("Testcase "+str(test_case)+": SKIPPED")
146 passed = False 146 passed = False
147 if passed: 147 if passed:
148 local_log.results("Testcase "+str(test_case)+": PASSED") 148 local_log.results("Testcase "+str(test_case)+": PASSED")
149 149
150 original_class.run = run 150 original_class.run = run
151 return original_class 151 return original_class