我正在尝试使用以下命令在python 3.6上使用pytest运行特定的测试方法:
pytest sanity_test.py::test_check
(如pytest docs中所述)
,它失败并显示以下错误消息:
ERROR: not found: <rootdir>/tests/automation/sanity/sanity_test.py::test_check
(no name '<rootdir>/tests/automation/sanity/sanity_test.py::test_check' in any of [<DoctestModule 'tests/automation/sanity/sanity_test.py'>, <Module
'tests/automation/sanity/sanity_test.py'>])
当我运行整个测试文件时,测试可以正常运行:
pytest sanity_test.py
当我尝试在隔离的项目中运行特定方法时,它会完美运行。
为什么pytest在我的项目中找不到专门的测试方法?
文件非常简单,看起来像这样:
def test_check():
pass