mbed-os

Dependents:   cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more

Committer:
be_bryan
Date:
Mon Dec 11 17:54:04 2017 +0000
Revision:
0:b74591d5ab33
motor ++

Who changed what in which revision?

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