【发布时间】:2022-02-25 06:35:06
【问题描述】:
我从这里安装了 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
我尝试使用命令对其进行测试:py.test --cov-report term --cov pytest.py。但它不起作用。即使我给出了 pytest.py 的整个绝对路径,它仍然没有数据可供收集。但是,如果我使用py.test pytest.py,它肯定测试过。
我对这个问题很困惑,谢谢你的帮助。
【问题讨论】:
-
使用前缀为“test_”的文件名,但在任何情况下都不要使用“pytest.py”,这会影响实际的“pytest”模块。
标签: python code-coverage pytest