,但在这个项目中,测试是在常规的模块,而不是模块标记test_stuff.py
Py.test不会找到我使用的是<code>pytest</code>测试
我试图通过change the test discovery在根加入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)
@jonrsharpe期待它没有拿起'.ini',这就是关键。我已经添加了细节。 –
它似乎根据文档类正在收集,而不是函数http://pytest.org/latest/customize.html#confval-python_classes – Srgrn
@jonrsharpe我看不出你的例子与我的不同。同样的结果。 –