Beispiel #1
0
# -*- coding: utf-8 -*-
# @Author  : zgh
# @Email   : [email protected]
# @File    : readExcel.py
# @Software: PyCharm

import os
from public.config import config
from openpyxl import load_workbook
from conf import Allpath
from public.logger import Log

logger = Log('auto_cases', Allpath.log_path)
url_1 = str(config().read_config(Allpath.http_conf_path, 'HTTP', 'url'))
mode = config().read_config(Allpath.case_conf_path, 'FLAG', 'mode')
logger.info("用例执行模式(0全部执行,1执行指定配置接口):%s" % mode)
logger.info("服务地址配置:%s" % url_1)
case_list = config().read_config(Allpath.case_conf_path, 'FLAG', 'case_list')
logger.info("配置用例列表:%s" % case_list)


class readExcel:
    def __init__(self, file, sheet):
        self.file = file
        self.sheet = sheet

    def read_Excel(self):
        rd = load_workbook(self.file)
        sheet = rd[self.sheet]
        logger.info('本次获取测试用例成功,表单:%s' % sheet)
Beispiel #2
0
 def __init__(self, config_path, conf):
     # 传入参数:路径、便签、对象
     self.config = config().read_config(config_path, 'DBCONFIG', conf)
     logger.info("本次数据库调用配置成功!")
Beispiel #3
0
from public.readExcel import readExcel
from public.writeExcel import writeExcel
from public.httpRequest import httpRequest
from conf import Allpath
from public.logger import Log

logger = Log('auto_cases', Allpath.log_path)

# url = config().read_config (Allpath.http_conf_path, 'REGISTER', 'recharge')
data1 = [{"id": 1, "url": "https://testdfind.citydo.com.cn/datawindow/os/user/login", "method": "POST", "code": "ok",
          "data": {"username": "******", "password": "******", "forceFlag": "true"}}]
h = readExcel(Allpath.test_data_path, 'Sheet1')
data2 = h.read_Excel()
# print(data2)
t = writeExcel(Allpath.test_data_path, 'Sheet1')
mode = config().read_config(Allpath.case_conf_path, 'FLAG', 'mode')
ID = config().read_config(Allpath.case_conf_path, 'FLAG', 'case_list')


@ddt  # 用ddt装饰我的测试类
class testHttpRequset(unittest.TestCase):
    def setUp(self):
        logger.info("============我要开始测试了===============")

    @data(*data2)  # 用data 来装饰我的测试用例
    # 加一个* 号可以进行区分单个执行
    @unpack
    def test_get(self, id, method, url, data, code, case_name, sql):
        logger.info('正在执行第%s条用例' % id)
        result_dict = {}
        logger.info("当前请求内容_URL:{};method:{};data:{};sql:{}".format(url, method, data, sql))