Exemplo n.º 1
0
# -*- coding: utf-8 -*-
# author: ext.zhangyue12
# datetime: 2021/3/15 14:49
# ide: PyCharm

from test_case.test_login import *
from common.Logs import Log

log = Log(__name__)
logger = log.Logger


def test_login():
    """
    定义一个全局变量,用来返回登录后的cookies,避免在pytest框架中重复操作
    :return:
    """

    global re_login_cookie
    login_url = server_ip('test') + "/fanwe/index.php?ctl=user&act=dologin&fhash" \
                                    "=IzHHyOyDiNsiYYYbamPlHqPQuWrWsCPGUKafBrbgqEymWQcfUP "
    username, password = get_excel_value(1)

    params = {
        "email": username,
        "user_pwd": password,
        "ajax": 1,
        "auto_login": 1
    }

    log = requests.post(url=login_url, data=params)
from common.Yaml_Data import HandleYaml
from common.Retrun_Response import dict_style
from Conf.conf import *
import allure
from common import Assert
from common import Consts

handleyaml = HandleYaml()
yamldict = handleyaml.get_data()

# log = Log(__name__)
# logger = log.Logger

file = os.path.basename(sys.argv[0])
print(file)
log = Log(file)
logger = log.Logger


@allure.description("测试http://calapi.51jirili.com/dream/categoryList接口")
@allure.testcase("http://calapi.51jirili.com/dream/categoryList", "测试用例地址👇")
def test_dream_categoryList():
    def_name = sys._getframe().f_code.co_name
    test_Assert = Assert.Assertions(def_name)
    logger.info("开始执行脚本%s:\n", def_name)
    url = server_ip('realse') + yamldict['test_dream_categoryList']['url']
    r = RequestsHandler().post_Req(url=url, json=yamldict['test_dream_categoryList']['json'],
                                   headers=yamldict['test_dream_categoryList']['headers'])
    sting_response = r.content.decode()
    json_response = dict_style(sting_response)
    # json_response = json.loads(sting_response)
Exemplo n.º 3
0
 def __init__(self, def_name):
     # self.log = Log.MyLog()
     self.def_name = def_name
     log = Log(def_name)
     self.logger = log.Logger