我正在开发一些测试包.
与CMD合作:
py.test --cov my_pkg
我用covarage得到了结果:
--------------- coverage: platform win32, python 2.7.9-final-0 ----------------
Name Stmts Miss Cover
---------------------------------------------------
my_pkg\__init__ 8 0 100%
my_pkg\general 2 0 100%
---------------------------------------------------
TOTAL 10 0 100%
失败:
当试图将它集成到pytest.main()并运行时:
python setup.py测试
以下内容:
============================= test session starts =============================
platform win32 -- Python 2.7.9 -- py-1.4.26 -- pytest-2.7.0
rootdir: C:\Users\kobi.kalif\Projects\automation_utilities, inifile:
plugins: cov, xdist
ERROR: file not found: --cov my_pkg
相关守则:
class PyTest(test_command):
"""class py.test for the testing
"""
user_options = []
def __init__(self, dist, **kw):
test_command.__init__(self, dist, **kw)
self.pytest_args = ["--cov my_pkg"]
.....
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
err_no = pytest.main(self.pytest_args)
sys.exit(err_no)
题:
如何在setup.py文件pytest.main中运行带覆盖的测试?
解决方法:
根据the documentation你应该这样做:
self.pytest_args = ["--cov", "my_pkg"]
要么:
self.pytest_args = "--cov my_pkg"
原文地址:https://codeday.me/bug/20190722/1504920.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。