我有一个调用
python方法的机器人框架测试套件.我希望该python方法在不失败测试的情况下将消息返回到控制台.具体来说,我正在尝试计划一个过程.
我可以使用“raise”将消息返回到控制台,但同时未通过测试.
def doSomething(self, testCFG={}):
'''
Do a process and time it.
'''
testCFG['operation'] = 'doSomething'
startTime = time.time()
response=self.Engine(testCFG)
endTime = time.time()
duration = int(round(endTime-startTime))
raise "doSomething took", duration//60 , "minutes and", duration%60, "seconds."
errmsg = 'doSomething failed'
if testCFG['code']: raise Exception(errmsg)
或者我可以使用“打印”将消息返回到日志文件并报告而不会使测试失败,但该信息仅在报告中可用,而不是在控制台中.
def doSomething(self, testCFG={}):
'''
Do a process and time it.
'''
testCFG['operation'] = '