Committer:
borlanic
Date:
Fri Mar 30 14:07:05 2018 +0000
Revision:
4:75df35ef4fb6
Parent:
0:380207fcb5c1
commentar

Who changed what in which revision?

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