Backup 1

Committer:
borlanic
Date:
Tue Apr 24 11:45:18 2018 +0000
Revision:
0:02dd72d1d465
BaBoRo_test2 - backup 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:02dd72d1d465 1 """
borlanic 0:02dd72d1d465 2 mbed SDK
borlanic 0:02dd72d1d465 3 Copyright (c) 2011-2015 ARM Limited
borlanic 0:02dd72d1d465 4
borlanic 0:02dd72d1d465 5 Licensed under the Apache License, Version 2.0 (the "License");
borlanic 0:02dd72d1d465 6 you may not use this file except in compliance with the License.
borlanic 0:02dd72d1d465 7 You may obtain a copy of the License at
borlanic 0:02dd72d1d465 8
borlanic 0:02dd72d1d465 9 http://www.apache.org/licenses/LICENSE-2.0
borlanic 0:02dd72d1d465 10
borlanic 0:02dd72d1d465 11 Unless required by applicable law or agreed to in writing, software
borlanic 0:02dd72d1d465 12 distributed under the License is distributed on an "AS IS" BASIS,
borlanic 0:02dd72d1d465 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
borlanic 0:02dd72d1d465 14 See the License for the specific language governing permissions and
borlanic 0:02dd72d1d465 15 limitations under the License.
borlanic 0:02dd72d1d465 16
borlanic 0:02dd72d1d465 17 Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
borlanic 0:02dd72d1d465 18
borlanic 0:02dd72d1d465 19 """
borlanic 0:02dd72d1d465 20
borlanic 0:02dd72d1d465 21 import sys
borlanic 0:02dd72d1d465 22
borlanic 0:02dd72d1d465 23 try:
borlanic 0:02dd72d1d465 24 from colorama import Fore
borlanic 0:02dd72d1d465 25 except:
borlanic 0:02dd72d1d465 26 pass
borlanic 0:02dd72d1d465 27
borlanic 0:02dd72d1d465 28 COLORAMA = 'colorama' in sys.modules
borlanic 0:02dd72d1d465 29
borlanic 0:02dd72d1d465 30
borlanic 0:02dd72d1d465 31 class IOperTestCaseBase():
borlanic 0:02dd72d1d465 32 """ Interoperability test case base class
borlanic 0:02dd72d1d465 33 @return list of tuple (severity, Description)
borlanic 0:02dd72d1d465 34 Example: (result.append((IOperTestSeverity.INFO, ""))
borlanic 0:02dd72d1d465 35 """
borlanic 0:02dd72d1d465 36
borlanic 0:02dd72d1d465 37 def __init__(self, scope=None):
borlanic 0:02dd72d1d465 38 self.PASS = 'PASS'
borlanic 0:02dd72d1d465 39 self.INFO = 'INFO'
borlanic 0:02dd72d1d465 40 self.ERROR = 'ERROR'
borlanic 0:02dd72d1d465 41 self.WARN = 'WARN'
borlanic 0:02dd72d1d465 42
borlanic 0:02dd72d1d465 43 self.scope = scope # Default test scope (basic, pedantic, mbed-enabled etc...)
borlanic 0:02dd72d1d465 44
borlanic 0:02dd72d1d465 45 def test(self, param=None):
borlanic 0:02dd72d1d465 46 result = []
borlanic 0:02dd72d1d465 47 return result
borlanic 0:02dd72d1d465 48
borlanic 0:02dd72d1d465 49 def RED(self, text):
borlanic 0:02dd72d1d465 50 return self.color_text(text, color=Fore.RED, delim=Fore.RESET) if COLORAMA else text
borlanic 0:02dd72d1d465 51
borlanic 0:02dd72d1d465 52 def GREEN(self, text):
borlanic 0:02dd72d1d465 53 return self.color_text(text, color=Fore.GREEN, delim=Fore.RESET) if COLORAMA else text
borlanic 0:02dd72d1d465 54
borlanic 0:02dd72d1d465 55 def YELLOW(self, text):
borlanic 0:02dd72d1d465 56 return self.color_text(text, color=Fore.YELLOW, delim=Fore.RESET) if COLORAMA else text
borlanic 0:02dd72d1d465 57
borlanic 0:02dd72d1d465 58 def color_text(self, text, color='', delim=''):
borlanic 0:02dd72d1d465 59 return color + text + color + delim
borlanic 0:02dd72d1d465 60
borlanic 0:02dd72d1d465 61 def COLOR(self, severity, text):
borlanic 0:02dd72d1d465 62 colors = {
borlanic 0:02dd72d1d465 63 self.PASS : self.GREEN,
borlanic 0:02dd72d1d465 64 self.ERROR : self.RED,
borlanic 0:02dd72d1d465 65 self.WARN : self.YELLOW
borlanic 0:02dd72d1d465 66 }
borlanic 0:02dd72d1d465 67 if severity in colors:
borlanic 0:02dd72d1d465 68 return colors[severity](text)
borlanic 0:02dd72d1d465 69 return text