bingmous

欢迎交流,不吝赐教~

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

统计

Python内置模块常用总结

目录

unittest

点击查看代码
import unittest
from htmltestreport import HTMLTestReport
class TestOne(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
print(f'setUpClass')
@classmethod
def tearDownClass(cls) -> None:
print(f'tearDownClass')
def setUp(self) -> None:
print(f'setUp')
def tearDown(self) -> None:
print(f'tearDown')
def test_01(self):
self.assertTrue(1 == 1)
def test_02(self):
self.assertEqual(1, 1, 'this is message')
if __name__ == '__main__':
"""pycharm里面执行是通过pycharm的插件执行的 自动识别了测试用例
如果要生成报告 需要通过python xxx.py执行
可以自己创建(填写脚本路径和工作目录 防止使用pycharm的工作目录)或者在没有单元测试的执行一次生成
"""
# run test
# unittest.main()
# generate report
test_suit = unittest.TestSuite()
test_suit.addTest(unittest.makeSuite(TestOne))
report = HTMLTestReport('report.html', "Title", "description")
print(f'finished')
res = report.run(test_suit)
print(f'finished')
report.generateReport(test_suit, res)

posted on   Bingmous  阅读(11)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 我与微信审核的“相爱相杀”看个人小程序副业
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· spring官宣接入deepseek,真的太香了~
点击右上角即可分享
微信分享提示