数据共享:在 conftest.py配置里写方 法可以实现数据共享, 不需要import导入。可 以跨文件共享
1、建立一个新的文件,文件名必须叫"conftest.py",然后写好公用的方法,加上@pytest.fixure
2、其他模块直接传入对应方法就可以

执行逻辑

系统执行到参数login时先从本文件中查找是否有这个名字的变量什么 的,之后在conftest.py中找是否有。


conftest.py文件如下:
import pytest
@pytest.fixture()
def login():
print('输入用户名密码登陆')

 

 

test_fixure.py文件如下
import pytest

def test_cart(login):
print('用例1,登陆后执行添加购物车功能操作')

def test_search():
print('用例2,不登陆查询功能操作')

def test_pay(login):
print('用例3,登陆后执行支付功能操作')

相关文章:

  • 2022-02-17
  • 2022-12-23
  • 2021-05-28
  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-01
  • 2022-12-23
  • 2020-06-12
  • 2022-12-23
  • 2021-08-15
  • 2021-07-04
相关资源
相似解决方案