首页 新闻 会员 周边 捐助

python执行完生成不出报告?

0
[待解决问题]

大神 帮忙看看  哪里错了  为啥执行完就是不出报告

代码:

# config:utf-8
import time, unittest
from utils.config import Config
from utils.loginclass import login_go
from driver.dr import Driver
from HTMLTestRunner import HTMLTestRunner
class Hzzh(unittest.TestCase):
def setUp(self):
driver = Driver(self)
self.driver = driver.choose_browser()
self.driver.get(Config().get('URL'))
time.sleep(5)

def test_01(self):
login_go(self.driver).login('cheb', 'cheng')
time.sleep(3)
try:
self.assertEqual(self.driver.find_element_by_id('navDivContainer').text, 'cheb')
print('登录成功!')
except:
print('登录失败,账号密码错误!')
self.driver.close()

def test_02(self):
login_go(self.driver).login('h1', '123456')
try:
self.assertEqual(self.driver.find_element_by_id('navDivContainer').text, '平台管理员')
print('登录成功!')
except:
print('登录失败,账号密码错误!')
self.driver.close()

def tearDown(self):
time.sleep(1)
# self.driver.quit()
print("over")
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(Hzzh("test_01"))
suite.addTest(Hzzh('test_02'))
now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
filename = "F:\\lianxi_007\\report\\" + now + " result.html"
with open(filename, "wb") as fp:
runner = HTMLTestRunner(
stream=fp,
title="测试报告",
description="用例执行情况"
)
runner.run(suite)
fp.close()






작은악마的主页 작은악마 | 菜鸟二级 | 园豆:212
提问于:2018-05-28 20:20
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册