我使用的是pytest
,但在这个项目中,测试是在常规模块中,而不是标记为test_stuff.py
的模块
我试图通过在项目的根目录中添加pytest.ini
文件来改变测试发现,其中包含以下内容:
[pytest]
python_files = *.py
python_functions=test_*
当我运行测试时,仍然没有找到:
$ py.test
================================ test session starts ================================
platform linux2 -- Python 2.7.6 -- py-1.4.20 -- pytest-2.5.2
collected 0 items
================================= in 0.03 seconds ==================================
我的布局再简单不过了:
$ ls
foo.py
pytest.ini
其中foo.py
包含:
def add(a, b):
return a+b
def test_add():
assert 4 == add(2, 2)
升级!
$ sudo pip install pytest --upgrade
此设置适用于pytest 2.8,不适用于2.5。