W2a*_*W2a 9 python pytest python-3.x
我有以下tests目录树:
tests/
subfolder_1/
test_1.py
subfolder_2/
subsubfolder/
subsubsubfolder/
test_2.py
Run Code Online (Sandbox Code Playgroud)
py.test 只找到test_1.py. 我怎样才能让它找到test_2.py?
Ian*_*nce 10
pytest 总是递归搜索,除非你另有说明(使用norecursedirs选项)。
如果 pytest 无法收集您的某些测试,请仔细检查:
testpaths配置模式下的某处(默认:当前目录),python_files配置模式(默认:test_*.py和*_test.py),python_classes配置模式(默认:)Test*,和python_functions配置模式(默认:)test*。Pytest查找名为或类似的文件时遇到一些问题test.py。尝试给它一个更专业的名称,例如test_subfolder1.pyandtest_subfolder2.py或 so。还要确保所有文件夹都是包,即__init__.py其中包含文件。