Python HTMLTestRunner安装 Python HTMLTestRunner库安装过程解析

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Python HTMLTestRunner安装 Python HTMLTestRunner库安装过程解析

十一的杂文录   2021-04-22 我要评论

安装 HTMLTestRunner 库的方法非常简单,直接 pip 就可以了

pip install html-testRunner

在 http://pypi.org/ 中可以直接搜索到,并且官方还提供了详细的文档,操作起来非常的简单

官方示例代码:

import HtmlTestRunner
import unittest


class 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. """
    pass
if __name__ == '__main__':
  unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='example_dir'))

这是运行后,生成的 HTML 网页

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们