linux 脚本函数后台执行 不回显,接口自动化框架从 windows 迁移至 linux 后执行脚本 htmltestrunner 中的 report 一直不显示...

执行代码如下

class AllTest:

def init(self):

global log, logger, resultPath, on_off

log = MyLog.get_log()

logger = log.get_logger()

resultPath = log.get_report_path()

on_off = localReadConfig.get_email("on_off")

#caselist 所有平台的 OP 接口,caselist1 为除 dmp 平台外的所有接口

self.caseListFile = os.path.join(readConfig.proDir, "caselist1.txt")

self.caseFile = os.path.join(readConfig.proDir, "testCase")

# self.caseFile = None

self.caseList = []

self.email = MyEmail.get_email()

# 添加需运行用例

def set_case_list(self):

fb = open(self.caseListFile)

for value in fb.readlines():

data = str(value)

if data != '' and not data.startswith("#"):

self.caseList.append(data.replace("\n", ""))

fb.close()

def set_case_suite(self):

self.set_case_list()

test_suite = unittest.TestSuite()

suite_module = []

for case in self.caseList:

case_name = case.split("/")[-1]

print(case_name+".py")

discover = unittest.defaultTestLoader.discover(self.caseFile, pattern=case_name + '.py', top_level_dir=None)

suite_module.append(discover)

print suite_module

if len(suite_module) > 0:

for suite in suite_module:

for test_name in suite:

test_suite.addTest(test_name)

else:

return None

return test_suite

def run(self):

"""

run test

:return:

"""

try:

suit = self.set_case_suite()

if suit is not None:

logger.info("*****TEST START**")

fp = open(resultPath, 'wb')

runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title='Test Report', description='Test Description')

runner.run(suit)

else:

logger.info("Have no case to test.")

except Exception as ex:

logger.error(str(ex))

finally:

logger.info("***TEST END******")

fp.close()

# send test report by email

if on_off == 'on':

self.email.send_email()

elif on_off == 'off':

logger.info("Don't send report email.")

else:

logger.info("Unknow state.")

if name == 'main':

obj = AllTest()

obj.run()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值