smart_brain_test/tests/__init__.py

56 рядки
1.6 KiB
Python

import report
import simulation.devices
from unittest.test import equivalency_chk
from unittest.jsonlog import TRUN_EXEC_LVL
DT_TOGGLE = 0.3
class test_collection(object):
TCEL_DICT = {
'full': report.TCEL_FULL,
'short': report.TCEL_SHORT,
'smoke': report.TCEL_SMOKE
}
def __init__(self, test_instance):
super().__init__()
self.test_instance = test_instance
def capabilities(self):
return ['full', 'short', 'smoke']
def command(self, command):
for member in self.test_instance.getmembers():
obj = self.test_instance.getobjbyname(member)
if id(obj) != id(self):
tcel = self.TCEL_DICT.get(command, report.TCEL_FULL)
self.test_instance.tcl[TRUN_EXEC_LVL] = tcel
obj.test_all(tcel)
class testcase(object):
METHOD_EXECUTED = {}
def __init__(self, tcl):
self.tcl = tcl
self.__test_list__ = []
def capabilities(self):
if len(self.__test_list__) > 0 and not 'test_all' in self.__test_list__:
self.__test_list__.append('test_all')
self.__test_list__.sort()
return self.__test_list__
def test_all(self, tcel=report.TCEL_FULL):
for tc_name in self.capabilities():
if tc_name != "test_all":
self.command(tc_name, tcel)
def command(self, command, tcel=report.TCEL_SINGLE):
simulation.devices.OUTPUT_ACTIVE = False
tc = getattr(self, command)
self.tcl[TRUN_EXEC_LVL] = tcel
tc(tcel)
simulation.devices.OUTPUT_ACTIVE = True