惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
雷峰网
雷峰网
S
Securelist
V
Vulnerabilities – Threatpost
S
SegmentFault 最新的问题
T
The Exploit Database - CXSecurity.com
A
About on SuperTechFans
T
Threat Research - Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
V
V2EX
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
L
Lohrmann on Cybersecurity
S
Security Affairs
S
Secure Thoughts
P
Privacy & Cybersecurity Law Blog
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cisco Talos Blog
Cisco Talos Blog
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
H
Heimdal Security Blog
L
LINUX DO - 热门话题
月光博客
月光博客
Apple Machine Learning Research
Apple Machine Learning Research
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
D
DataBreaches.Net
N
Netflix TechBlog - Medium
The Hacker News
The Hacker News
N
News and Events Feed by Topic
C
Check Point Blog
博客园_首页
Scott Helme
Scott Helme
T
Troy Hunt's Blog
U
Unit 42

博客园 - 林杰的博客

7z系列之一:7zip SDK中C++模块的编译 WORD2012 中使用“全屏阅读” Office2012中使用“冻结窗格”功能锁定标题栏 开发工具:Visual Studio 2005下方便宜用的代码行统计工具 为Visual Assist设置快捷键 Visual Studio 2010的Python支持工具 Linux 使用pid文件结束nginx 让Win7资源管理器显示图片内容预览 Linux 系统安装配置NTP时间服务器 Editplus中.proto文件的高亮文件 c#美味: 微软图表控件MSChart安装部署 测试工具:用性能监视器查看程序的性能 C#美味:Linq入门 讲座 C++零食:使用Unicode版的预定义宏__FUNCTION__ C++零食:VC中使用ForceInclude来强制包含stdafx.h C++零食:重启后消失的注册表键值 C++零食:WTL中使用双缓冲避免闪烁 C++零食:wprintf 中使用%I64d格式化输出LONGLONG C++零食:HRESULT 与 Windows Error Codes 不是一回事
Python 单元测试带案例名称输出
林杰的博客 · 2011-03-17 · via 博客园 - 林杰的博客

python下使用默认的单元测试执行的时候是没有案例名称输出的。

代码如下:

import unittest

class DemoTestCase(unittest.TestCase):

    def setUp(self):
        pass

    def test_demo(self):
        
        self.assertEqual(1, 1)

    def tearDown(self):
        return


if __name__ == '__main__':
    unittest.main()

执行后输出如下:

.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

因为有比较多案例,我很想能有带案例名得输出,查找了资料下,改动如下即可:

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(DemoTestCase)
    unittest.TextTestRunner(verbosity=2).run(suite


新的输出如下:

test_demo (__main__.DemoTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.000s

OK