[英]Using py.test --cov from inside setup.py pytest.main
I'm developing a package with some testing. 我正在开发一些测试包。
Working with CMD: 与CMD合作:
py.test --cov my_pkg
I get the results with covarage: 我用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%
Fails: 失败:
when trying to integrate it inside pytest.main()
and running with: 当试图将它集成到pytest.main()
并运行时:
python setup.py test
with the following: 以下内容:
============================= 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
Relevant Code: 相关守则:
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)
Question: 题:
How can i run tests with coverage from inside the setup.py
file pytest.main
? 如何在setup.py
文件pytest.main
运行带覆盖的测试?
According to the documentation you should either do: 根据文档,你应该做:
self.pytest_args = ["--cov", "my_pkg"]
or: 要么:
self.pytest_args = "--cov my_pkg"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.