python使用HTMLTestRunner導(dǎo)出餅圖分析報(bào)告的方法
更新時(shí)間:2019年12月30日 15:34:52 作者:春天的菠菜
這篇文章主要介紹了python使用HTMLTestRunner導(dǎo)出餅圖分析報(bào)告的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
目錄如下:
這里有使用
HTMLTestRunner和 echarts.common.min.js文件[見(jiàn)百度網(wǎng)盤,這里給自己留個(gè)記錄便于查詢]
unit_test.py代碼如下:
import unittest import requests import time import os.path from common import HTMLTestRunner class TestLogin(unittest.TestCase): def setUp(self): # 獲取session對(duì)象 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("用戶名或密碼錯(cuò)誤", 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("用戶名或密碼錯(cuò)誤", 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'測(cè)試報(bào)告', description=u'用例執(zhí)行情況') runner.run(test) file_result.close()
運(yùn)行產(chǎn)生報(bào)告查看報(bào)告:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- Python HTMLTestRunner如何下載生成報(bào)告
- Python HTMLTestRunner測(cè)試報(bào)告view按鈕失效解決方案
- Python HTMLTestRunner庫(kù)安裝過(guò)程解析
- Python HTMLTestRunner可視化報(bào)告實(shí)現(xiàn)過(guò)程解析
- 詳解python3中用HTMLTestRunner.py報(bào)ImportError: No module named ''StringIO''如何解決
- 解決python3運(yùn)行selenium下HTMLTestRunner報(bào)錯(cuò)的問(wèn)題
- 解決python3 HTMLTestRunner測(cè)試報(bào)告中文亂碼的問(wèn)題
- python使用 HTMLTestRunner.py生成測(cè)試報(bào)告
- Python unittest如何生成HTMLTestRunner模塊
相關(guān)文章
Python Django框架介紹之模板標(biāo)簽及模板的繼承
今天給大家?guī)?lái)Python Django框架的相關(guān)知識(shí),文中對(duì)模板標(biāo)簽及模板的繼承介紹的非常詳細(xì),對(duì)正在學(xué)習(xí)python的小伙伴們有很好地幫助,需要的朋友可以參考下2021-05-05學(xué)生如何注冊(cè)Pycharm專業(yè)版以及pycharm的安裝
這篇文章主要介紹了學(xué)生如何注冊(cè)Pycharm專業(yè)版以及pycharm的安裝,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09Python序列化與反序列化相關(guān)知識(shí)總結(jié)
今天給大家?guī)?lái)關(guān)于python的相關(guān)知識(shí),文章圍繞著Python序列化與反序列展開(kāi),文中有非常詳細(xì)的介紹,需要的朋友可以參考下2021-06-06使用Python和jieba庫(kù)生成中文詞云的示例代碼
在文本分析和數(shù)據(jù)可視化的領(lǐng)域中,詞云是一種展示文本數(shù)據(jù)中關(guān)鍵詞頻率的直觀方式,Python作為一種強(qiáng)大的編程語(yǔ)言,提供了多種庫(kù)來(lái)幫助我們生成詞云,在本文中,我們將通過(guò)一個(gè)簡(jiǎn)單的示例,展示如何使用Python生成中文詞云,需要的朋友可以參考下2024-07-07