run方法

def run_t():
    try:
        log = InsertLog_P()
        dirpath = './scripts'
        discover = unittest.defaultTestLoader.discover(dirpath,pattern='*_tc.py')
        suite = get_test_case(discover)
        ct = time.strftime('%y%m%d%H%M%S ')
        filedir = './reports/' + 'report' + ct + '.html'
        fp = open(filedir,'w')
        runner = HTMLTestRunner(stream=fp,title=u'test',description=u'description' )
        runner.run(suite)
        fp.close()
        log.info(u"脚本成功运行")

    except BaseException as msg:
        log.error(msg)

  

posted @ 2018-08-19 16:17  ~小浪呆呆  阅读(158)  评论(0编辑  收藏  举报