use*_*671 8 python code-coverage pytest
我从这里安装了pytest插件:http://pypi.python.org/pypi/pytest-cov.然后我有一个简单的测试代码:
pytest.py:
class TestNumbers:
def test_int_float(self):
assert 1 == 1.0
def test_int_str(self):
assert 1 == 1
Run Code Online (Sandbox Code Playgroud)
我试着用命令测试它:'py.test --cov-report term --cov pytest.py'.但它不起作用.即使我给出了pytest.py的完整绝对路径,它仍然没有收集数据.但是,如果我使用py.test pytest.py,肯定测试好了.
我很困惑这个问题,谢谢你的帮助.
Joh*_*ter 15
尝试:
py.test --cov-report term --cov=. test.py
Run Code Online (Sandbox Code Playgroud)
该--cov参数采用一个参数来说明要覆盖哪些路径.在你的例子中,--cov会消耗test.py,但是py.test没有关于要测试哪些文件的参数.
更新:正如@ hpk42指出的那样,你需要将你的例子称为其他东西pytest.py.当我在本地做到这一点时,我打电话给它test.py.
| 归档时间: |
|
| 查看次数: |
8138 次 |
| 最近记录: |