[英]How do I get pytest to run all functions as test
I have looked around and I can't find a pytest.ini flag to pass in that says the equivalent of 我环顾四周,找不到pytest.ini标志传递,该标志表示
def test_one():
# you run this by default
def two():
# despite not having test in the name you should also run this
reason: test function name lengths are getting to long when I'm being descriptive with naming and frankly it seems anti dry. 原因:当我使用命名进行描述时,测试功能名称的长度越来越长,坦率地说,它似乎很干燥。
From 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
Replace *_check
with just *
in there and you're set. 替换
*_check
只有*
在那里,你设置。
Try this as shown below, it will ask py.test collection tests from all python files. 尝试如下所示,它将要求所有python文件进行py.test集合测试。
# content of pytest.ini
[pytest]
python_files = *.py
you can check this part of document, 您可以检查文档的这一部分,
customizing test collection to find all .py files 自定义测试集合以查找所有.py文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.