我在从PyCharm内部运行pytest测试时遇到问题
我在C:\Temp中一个名为agent_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”-路径C:/Temp/agents_automation_2
在C:\Temp\agents_automation_2中使用参数C:/Temp/agents_automation_2启动py.test
=============================测试 session 开始=================== ===========
平台Win32-Python 3.6.4,pytest-3.4.2,py-1.5.2,pluggy-0.6.0
rootdir:C:\Temp\agents_automation_2,ini文件:
插件:xdist-1.22.0,forked-0.2
收集了0个项目
========================= 0.01秒内没有运行测试===================== =====
但是,当我从文件夹内的常规Windows命令行运行时,测试运行正常
知道可能是什么问题吗?
谢谢 !!!
最佳答案
测试文件的名称不符合默认的pytest发现规则。如果将x_tests.py更改为x_test.py,它将运行测试并按预期失败。请查看this page,以获取有关pytest发现规则的更多信息。
关于python-3.x - 从pycharm使用pytest运行时获取空测试套件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49367826/