這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)怎么在python中使用HTMLTestRunner導(dǎo)出餅圖分析報告,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
目錄如下:
這里有使用
HTMLTestRunner和 echarts.common.min.js文件[見百度網(wǎng)盤,這里給自己留個記錄便于查詢]
unit_test.py代碼如下:
import unittest import requests import time import os.path from common import HTMLTestRunner class TestLogin(unittest.TestCase): def setUp(self): # 獲取session對象 self.session = requests.session() # 登錄url self.url = 'http://XXXXXX/oauth/oauth/token' def test_login_success(self): data = { 'grant_type': 'password', 'username': 'iu', 'password': '111', 'client_id': 'web', 'client_secret': 'web-secret' } r = self.session.post(url=self.url, data=data) try: self.assertEqual(r.json()['token_type']) except AssertionError as e: print(e) def test_username_not_exit(self): data = { 'grant_type': 'password', 'username': '322u', 'password': '8', 'client_id': 'web', 'client_secret': 'web-secret' } r = self.session.post(url=self.url, data=data) try: self.assertEqual("用戶名或密碼錯誤", r.json()["error_description"]) except AssertionError as e: print(e) def test_password_error(self): data = { 'grant_type': 'password', 'username': '2u', 'password': '888ssss888', 'client_id': 'web', 'client_secret': 'web-secret' } r = self.session.post(url=self.url, data=data) try: self.assertEqual("用戶名或密碼錯誤", r.json()["error_description"]) except AssertionError as e: print(e) def tearDown(self): self.session.close() if __name__ == '__main__': # unittest.main() test = unittest.TestSuite() test.addTest(TestLogin('test_login_success')) test.addTest(TestLogin('test_username_not_exit')) test.addTest(TestLogin('test_password_error')) rq = time.strftime('%Y%m%d%H%M', time.localtime(time.time())) file_path = os.path.abspath('.') + '\\report\\' + rq + '-result.html' file_result = open(file_path, 'wb') runner = HTMLTestRunner.HTMLTestRunner(stream=file_result, title=u'測試報告', description=u'用例執(zhí)行情況') runner.run(test) file_result.close()
運行產(chǎn)生報告查看報告:
上述就是小編為大家分享的怎么在python中使用HTMLTestRunner導(dǎo)出餅圖分析報告了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
網(wǎng)頁標題:怎么在python中使用HTMLTestRunner導(dǎo)出餅圖分析報告-創(chuàng)新互聯(lián)
網(wǎng)站路徑:http://www.rwnh.cn/article18/pcodp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計、移動網(wǎng)站建設(shè)、網(wǎng)站策劃、外貿(mào)網(wǎng)站建設(shè)、搜索引擎優(yōu)化、網(wǎng)站維護
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容