Python HTMLTestRunner庫安裝過程解析
安裝 HTMLTestRunner 庫的方法非常簡單,直接 pip 就可以了
pip install html-testRunner
在 https://pypi.org/ 中可以直接搜索到,并且官方還提供了詳細的文檔,操作起來非常的簡單
官方示例代碼:
import HtmlTestRunnerimport unittestclass TestStringMethods(unittest.TestCase): def test_upper(self): self.assertEqual(’foo’.upper(), ’FOO’) def test_error(self): ''' This test should be marked as error one. ''' raise ValueError def test_fail(self): ''' This test should fail. ''' self.assertEqual(1, 2) @unittest.skip('This is a skipped test.') def test_skip(self): ''' This test should be skipped. ''' passif __name__ == ’__main__’: unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output=’example_dir’))
這是運行后,生成的 HTML 網頁
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。
相關文章:
1. Docker究竟是什么 為什么這么流行 它的優點和缺陷有哪些?2. ASP.NET MVC實現城市或車型三級聯動3. JS中的常見數組遍歷案例詳解(forEach, map, filter, sort, reduce, every)4. Java 批量獲取地址間距離工具(支持中轉站)5. python如何用matplotlib創建三維圖表6. Python使用Pyqt5實現簡易瀏覽器(最新版本測試過)7. Element ui tree(樹)實現父節點選中時子節點不選中父節點取消時子節點自動取消功能8. 如何在.net6webapi中使用自動依賴注入9. ASP中格式化時間短日期補0變兩位長日期的方法10. java實現彈球小游戲
