Exemplo n.º 1
0
def db():
    return eval(DataRead().read_ini(ENVPATH, 'db'))
Exemplo n.º 2
0
'''
注册接口的脚本
'''

# pytest fixture参数化
import pytest

from JinRongZongHe.baw.DbOp import DbOp
from JinRongZongHe.baw.Member import Member
from JinRongZongHe.caw.DataRead import DataRead
from JinRongZongHe.test_script.conftest import db
from JinRongZongHe.caw.Assert import Assert


@pytest.fixture(params=DataRead().read_yaml(r"data_case\register_fail.yaml"))
def fail_data(request):
    return request.param


@pytest.fixture(params=DataRead().read_yaml(r"data_case\register_success.yaml")
                )
def success_data(request):
    return request.param


@pytest.fixture(params=DataRead().read_yaml(r"data_case\register_repeat.yaml"))
def repeat_data(request):
    return request.param


#注册失败的逻辑
Exemplo n.º 3
0
def url():
    return DataRead().read_ini(ENVPATH, 'url')


# 读取环境文件,获取db
@pytest.fixture(scope='session')
def db():
    return eval(DataRead().read_ini(ENVPATH, 'db'))


# BaseRequests实例化,整个执行过程实例化一次
@pytest.fixture(scope='session')
def base_requests():
    return BaseRequests()


@pytest.fixture(scope="session",
                params=DataRead().read_yaml(r"data_case\login_setup.yaml"))
def setup_data(request):
    return request.param


@pytest.fixture(scope="session")
def register(setup_data, db, url, base_requests):
    # 注册成功
    r = Member().register(url, base_requests, setup_data["data"])
    Assert().equal(setup_data['expect'], r.json(), "msg,status,code")
    yield
    # 清理注册用户
    DbOp().delete_user(db, setup_data["data"]["mobilephone"])
Exemplo n.º 4
0
def url():
    return DataRead().read_ini(ENVPATH, 'url')
Exemplo n.º 5
0
'''
登录接口的脚本
'''
import pytest

from JinRongZongHe.baw.DbOp import DbOp
from JinRongZongHe.baw.Member import Member
from JinRongZongHe.caw.DataRead import DataRead
from JinRongZongHe.test_script.conftest import db, BaseRequests
from JinRongZongHe.caw.Assert import Assert

@pytest.fixture(params=DataRead().read_yaml(r"data_case\login_data.yaml"))
def login_data(request):
    return request.param

# 登录的逻辑
def test_login(register, url, base_requests,login_data):
    # print(f"执行登录失败的用例,测试数据为:{login_data}")
    r = Member().login(url, base_requests, login_data["data"])
    Assert().equal(login_data['expect'], r.json(), "msg,status,code")


# #登录失败的逻辑
# def test_login_fail(fail_data,url,base_requests):
#     print(f"执行登录失败的用例,测试数据为:{fail_data}")
#     r=Member().login(url,base_requests,fail_data["data"])
#     Assert().equal(fail_data['expect'], r.json(), "msg,status,code")
#
# # 登录成功的逻辑
# def test_login_success(success_data,url,db,base_requests):
#     print(f"执行登录成功的用例,测试数据为:{success_data}")
Exemplo n.º 6
0
'''
登录接口的脚本
'''

import pytest

from JinRongZongHe.caw.DataRead import DataRead
from JinRongZongHe.caw.Assert import Assert
from JinRongZongHe.baw.Member import Member
from JinRongZongHe.baw.DbOp import DbOp

@pytest.fixture(params=DataRead().read_yaml(r"data_case/login_fail.yaml"))
def fail_data(request):
    return request.param

@pytest.fixture(params=DataRead().read_yaml(r"data_case/login_success.yaml"))
def success_data(request):
    return request.param

# 登录失败的逻辑
def test_login_fail(fail_data,url,base_requests):
    print(f"执行登录失败的用例,测试数据为:{fail_data}")
    r = Member().login(url,base_requests,fail_data['data'])
    print(r.text)
    Assert().equal(fail_data['expect'],r.json(),"msg,status,code")

# 登录成功的逻辑
def test_login_success(success_data,url,base_requests):
    print(f"执行登录成功的用例,测试数据为:{success_data}")
    r = Member().login(url,base_requests,success_data['data'])
    print(r.text)
Exemplo n.º 7
0
def db():
    return eval(DataRead().read_ini(ENVPATH, "db"))
Exemplo n.º 8
0
@pytest.fixture(scope="session")
def url():
    return DataRead().read_ini(ENVPATH, "url")


@pytest.fixture(scope="session")
def db():
    return eval(DataRead().read_ini(ENVPATH, "db"))


# BaseRequests实例化,整个执行过程实例化一次
@pytest.fixture(scope="session")
def base_requests():
    return BaseRequests()


@pytest.fixture(params=DataRead().read_yaml(r"data_case/login_setup.yaml"))
def setup_data(request):
    return request.param


# 用session保证先执行这个
@pytest.fixture()
def register(setup_data, db, url, base_requests):
    # 注册用户
    r = Member().register(url, base_requests, setup_data["data"])
    yield
    # 删除注册用户
    DbOp().delete_user(db, setup_data["data"]["mobilephone"])
Exemplo n.º 9
0
# pytest fixture 参数化的功能
# 参数都进来
import pytest

from JinRongZongHe.baw.member import Member
from JinRongZongHe.caw.Assert import Assert

from JinRongZongHe.caw.DataRead import DataRead
from JinRongZongHe.baw.DbOp import DbOp

# list 多组测试数据
from JinRongZongHe.test_script.conftest import url, base_requests


@pytest.fixture(params=DataRead().read_yaml(r"data_case\register_fail.yaml"))
def fail_data(request):
    return request.param


@pytest.fixture(params=DataRead().read_yaml(r"data_case\zhuce_success.yaml"))
def success_data(request):
    return request.param


@pytest.fixture(params=DataRead().read_yaml(r"data_case\denglu_failed.yaml"))
def login_fail_data(request):
    return request.param


@pytest.fixture(params=DataRead().read_yaml(r"data_case\denglu_success.yaml"))