python - python根据属性跳过单元测试
问题描述
我们使用 python unittest模块和鼻子进行测试,以从它们各自的优势中受益。Nose 使我们能够使用 跳过命令行上的某些测试nose.plugins.attrib
,例如:
import nose.plugins.attrib
@nose.plugins.attrib.attr('slow')
class Testdiskio(unittest.TestCase):
r'slow running disk intensive tests'
然后从命令行我们使用python setup.py nosetests -A "not slow"来运行我们的快速测试。在这种情况下,我们想要运行所有东西,包括磁盘密集型测试,我们使用:python setup.py nosetests
但是python的unittest没有这样的选择。我们已经尝试调整unittest.skipIf
装饰器,但是没有机制可以从命令行传递选项来有条件地测试skipIf
.
只是想知道是否有人提出了一种解决方案,可以从命令行选择性地运行/跳过针对 python unittest 模块的测试?
解决方案
推荐阅读
- spring - Spring JPA 跨不同模式查询同一张表
- javascript - Firebase 云功能更新记录并发送通知
- cgi - 使用 GET 参数在命令行上运行二进制 CGI 文件
- android - 在 Android 模拟器和物理设备中运行程序的区别?
- r - R中一组列的热编码
- python - 使用特定跨度类 python selenium 获取页面中的所有元素
- java - Piccaso.into 方法,根据 ImageView 的 scaleType 属性加载图像后是否进行缩放?
- android - Android Google 文字转语音引擎:在没有互联网连接的情况下安装语音
- python - 每当在列中遇到 0 时,Python Pandas 都会与先前的值相加
- windows - 我在我的 Windows 批处理脚本中做错了什么,我试图了解脚本背后的逻辑