我在从 PyCharm 内部运行 pytest 测试时遇到问题
我在 C:\Temp 中名为 agents_automation_2 的文件夹中有一个文件 x_tests.py,该文件的内容是
import pytest
def test_mytest():
assert False
当我运行时,我得到以下输出
C:\Python36-32\python.exe “C:\Program Files\JetBrains\PyCharm 2017.3.2\helpers\pycharm_jb_pytest_runner.py” –path C:/Temp/agents_automation_2 使用参数启动 py.test C:/Temp/ C:\Temp\agents_automation_2 中的 agents_automation_2 ============================= 测试会话开始 ========== =================== 平台 win32——Python 3.6.4、pytest-3.4.2、py-1.5.2、pluggy-0.6.0 根目录:C:\ Temp\agents_automation_2, inifile: plugins: xdist-1.22.0, forked-0.2 collected 0 items ======================== 没有测试在 0.01 秒内运行=========================
但是,当我从文件夹内的常规 Windows 命令行运行时,测试运行正常
知道可能是什么问题吗?
谢谢 !!!
原文由 David Fliguer 发布,翻译遵循 CC BY-SA 4.0 许可协议
您的测试文件的名称不符合默认的 pytest 发现规则。如果将 _xtests.py 更改为 _xtest.py ,它会运行测试并按预期失败。查看 此页面 以获取有关 pytest 发现规则的更多信息。