我尝试使用pycharm运行以下简单的测试用例,当我运行这些测试用例时,我看到了输出
Process finished with exit code 0
而是通过/失败。在
我运行的测试用例:
import pytest
from pytest1 import can_p1
msg=0
@pytest.fixture(scope = "module")
def msgFraming():
print ("I'm inside FIXTURE")
nchannel = 686
FuncID = 144
opType = 8
FuncID = FuncID * 2
msg = nchannel+FuncID+opType
return msg
def test_cansendMsg(msgFraming):
res= can_p1.canMsgsend(msg)
assert res == msg
def test_canrecvMsg(msgFraming):
res = can_p1.canMdgrcv(msg)
assert res == msg
我在IDE中编辑了如下设置:
1)文件->设置->工具->python集成工具->将默认设置为py.测试在
当我运行其他程序(除了pytest)时,我可以看到o/p
也许在使用pytest之前已经运行了函数,那么pycharm将使用python(而不是pytest)自动创建一个配置,因此删除run/debug配置中的相关python配置(或所有python)(不要忘记应用)
您配置的设置正确。下一步是为测试创建一个新的运行配置。右键单击文件中的任意位置并导航上下文菜单。查找标记为
Create 'py.test in <file_name>.py'...
的选项。选择它,就会弹出一个窗口,显示PyCharm将为您的测试文件创建的配置。在这里,您可以添加对配置的修改(目标字段应该已经填充了正确的信息)。完成后,单击“应用”,然后单击“确定”。然后,您可以使用这个配置运行PyTest,方法是从绿色run按钮左侧的下拉列表中选择它。一旦你选择了它,点击运行按钮,开始吧!在相关问题 更多 >
编程相关推荐