def __init__(self, tcObj, startStatus, strategy): self.startStatus = startStatus self.tlog = tcObj.tlog self.strategy = "product" if strategy == "all" else strategy self.isAcceptHandler = tcObj.__isAccept__ self.isContinueHandler = tcObj.__isContinue__ self.getStepArgHandler = tcObj.__getArgList__ self.isDebug = tcObj.__isDebug__() testSteps = TValueGroup({}) for sFunName in [ funName for funName in dir(tcObj) if not funName.startswith("__") ]: sFun = eval("tcObj.%s" % sFunName) if (hasattr(sFun, '__name__') and sFun.__name__ == 'stepDecorator'): sFunStatus = sFun() testSteps[sFunName] = { 'or': sFunStatus[0].split(','), 'to': sFunStatus[1], 'repeat': sFunStatus[2], 'cover': {} } self.testSteps = testSteps
def getTCInfo(self, tcName): if not self.tcInfos.keys().__contains__(tcName): tcInfo = TValueGroup({}) tcInfo.Orders = None tcInfo.isTested = False self.tcInfos[tcName] = tcInfo return self.tcInfos[tcName]
def __init__(self): self.runModeEnum = {'slook':-22, 'scenario':-21, 'param':-11, 'look':-10, 'show':-9, 'debug':0, 'run':9, 'rerun':10, 'stop':-9} self.testResInfo = ['Passed', 'Warned', 'Failed', 'NotRun'] self.tlog = TestLoggerFactory() self.tprop = IniConfigure("mtest.ini") self.tassert = TestAssert(self.tlog) self.tcInfos = TValueGroup({}) self.init()
def _getNextParam(self): if self.isList: strategyParam = TValueGroup({}) else: strategyParam = TValueGroup(self.tParam, True, isDeepClone=True) strategyParam.pIndex = self.curParamIndex strategyParam.paramName = None strategyParam.orderNum = self.curOrderNum self.__renderParam__(strategyParam) if self.isPureNum: self.curOrderNum = self.gcombSp.getNextPureOrderNum( self.curOrderNum) else: self.curOrderNum += 1 return strategyParam
def __init__(self, tParam, whereCondition, group): self.tParam = TValueGroup(tParam) self.condition = ObjOperation.tryGetVal(whereCondition, "condition", None) self.combSp = self.__combParam__(tParam, whereCondition, group) self.totalParams = self.combSp.getTotalNum() self.curOrderNum = 0 self.curParamIndex = 0
def addModelCls(self, modelClass, testModule, testName, imports, testOrder, searchKey): tcInfo = self.tc.getTCInfo(modelClass.__name__) for caseFun in dir(modelClass): if not MTConst.sysFunReg.isMatch(caseFun): testCaseInfo = TValueGroup({}) testCaseInfo.Name = caseFun tcInfo[caseFun] = {} tcInfo.Module = testModule tcInfo.Name = testName if testName != None else modelClass.__name__ tcInfo.Imports = imports tcInfo.Orders = testOrder tcInfo.SearchKey = searchKey
def __addPathToArgPathContainer(self, argPathContainer, testPath, repeatCount): pathParam = TValueGroup({}) stepIndexList = [] stepIndexToCombIndex = {} isCondCover = self.strategy == "condition" isEdgeCover = self.strategy == "edge" or self.strategy == "condEdge" or isCondCover notCondCover = self.strategy == "path" or self.strategy == "edge" or self.strategy == 'available' noNewEdge, stepIndex, combIndex = self.__prepareTestPath( testPath, pathParam, stepIndexList, stepIndexToCombIndex, isEdgeCover, isCondCover) if isEdgeCover and noNewEdge: return pathCovered = False stepArg = CombineSingleParam(pathParam, { 'combine': stepIndexList, 'strategy': self.strategy }, None) while True: pathArg = stepArg.nextParam() if pathArg == None: break acceptRes, acceptStepIndex = self.__isTestPathAccept( testPath, pathArg) if acceptRes <= 9: addTestPath = testPath if stepIndex > acceptStepIndex: addTestPath = list(testPath) delStepIndex = stepIndex while delStepIndex > acceptStepIndex: addTestPath.__delitem__(delStepIndex) pathArg.__delitem__(delStepIndex) delStepIndex -= 1 pathCovered = True argPathContainer.append({ 'path': addTestPath, 'accept': acceptRes, 'arg': pathArg }) if notCondCover: break addCombIndex = ObjOperation.tryGetVal(stepIndexToCombIndex, acceptStepIndex, combIndex) if addCombIndex < combIndex: stepArg.toNextParamArg(addCombIndex) if isEdgeCover and pathCovered: self.__coverTestPath(testPath)
def diffJson(self, jsonStr, jsonStr2): return "%s\n%s" % ObjOperation.jsonEqual( TValueGroup(jsonStr).__prop__, TValueGroup(jsonStr2).__prop__)
def __init__(self): self.property = tprop self.tassert = tassert self.tlog = tlog self.param = TValueGroup({})
def testtvg(self): self.tlog.info(JsonParser().toStr({'a': TValueGroup({'b': 1})}))