如何让pytest运行所有函数作为测试

时间:2016-07-01 23:56:23

标签: python unit-testing pytest

我环顾四周,找不到传递的pytest.ini标志,相当于

def test_one():
   # you run this by default

def two():
   # despite not having test in the name you should also run this

原因:当我用命名描述时,测试函数名称的长度变得越来越长,坦率地说它似乎是反干的。

2 个答案:

答案 0 :(得分:1)

来自documentation

# content of setup.cfg
# can also be defined in in tox.ini or pytest.ini file
[pytest]
python_files=check_*.py
python_classes=Check
python_functions=*_check

将“*_check替换为*,然后设置。

。”

答案 1 :(得分:0)

尝试如下所示,它将从所有python文件中询问py.test集合测试。

# content of pytest.ini
[pytest]
python_files = *.py

你可以查看这部分文件,

customizing test collection to find all .py files