Esempio n. 1
0
class Conf:

    def __init__(self):
        self.conf = configparser.ConfigParser()
        self.getpath = GetPath()

    #获取配置文件内数据 并通过base文件内容判断调用哪一个配置环境
    def get_base_url(self,section,option):
        file_name_path = self.getpath.get_conf_path_base()
        self.conf.read(file_name_path,encoding='utf-8')
        if self.get_boolean('switch','button'):
            file_1 = self.getpath.get_conf_environment_1()
            self.conf.read(file_1,encoding='utf-8')
            return self.conf[section][option]
        else:
            file_1 = self.getpath.get_conf_environment_2()
            self.conf.read(file_1,encoding='utf-8')
            return self.conf[section][option]

    #返回bool类型
    def get_boolean(self,section,option):
        return self.conf.getboolean(section,option)

    #返回int类型
    def get_int(self,section,option):
        return self.conf.getint(section,option)

    #返回float类型
    def get_float(self,section,option):
        return self.conf.getfloat(section,option)
Esempio n. 2
0
    def __init__(self):

        self.formatter = logging.Formatter('%(asctime)s - %(levelname)s- %(message)s')

        #设置日志收集器
        self.my_logger = logging.getLogger('十月')
        self.my_logger.setLevel("DEBUG")

        #设置输出日志
        self.fh = logging.FileHandler(GetPath().get_logs_path(),encoding='utf-8')
        self.fh.setLevel('DEBUG')
        self.fh.setFormatter(self.formatter)

        #对接
        self.my_logger.addHandler(self.fh)
Esempio n. 3
0
# @function : 充值模块
"""

import json
import unittest
from ddt import ddt, data
from common import request
from common.main import Runner
from common.loggers import Log
from common.do_excel import Do_Excel
from common.contants import GetPath
from common.basic_data import Context
# from testcase.mysql_datas import SelectPhone

datas, sheet_name = Runner('recharge').get_execl_datas()
get_do_excel = Do_Excel(GetPath().get_datas_path())


@ddt
class TestRecharge(unittest.TestCase):

    # classmethod
    # def setUpClass(cls):
    #     sql = 'SELECT * FROM future.member WHERE member.MobilePhone = 15680978629'
    #     SelectPhone()

    @data(*datas)
    def test_recharge(self, item):
        python_dict = json.loads(item.request_data)
        try:
            # 调用url进行拼接
Esempio n. 4
0
import unittest
import HTMLTestRunnerNew
# from testcase.test_login import TestLogin
# from testcase.test_register import TestRegister
# from BeautifulReport import BeautifulReport

from testcase.test_recharge import TestRecharge
from common.contants import GetPath

#为测试集开辟存储空间
test_suite = unittest.TestSuite()

#加载测试用例
test_loader = unittest.TestLoader()

# test_suite.addTest(test_loader.loadTestsFromTestCase(TestRegister))   # 注册
# test_suite.addTest(test_loader.loadTestsFromTestCase(TestLogin))      # 登录
test_suite.addTest(test_loader.loadTestsFromTestCase(TestRecharge))  # 充值

# runner = unittest.TextTestRunner()
# runner.run(test_suite)

#执行测试用例,并输出测试报告
# BeautifulReport(test_suite).report(description='API接口测试', filename='API测试报告', log_path=GetPath().get_report_path())

with open(GetPath().get_report_path(), mode='wb+') as file:
    file_test = HTMLTestRunnerNew.HTMLTestRunner(file,
                                                 description='api测试报告_2',
                                                 title='api测试报告_2',
                                                 tester='MLY-ZONE')
    file_test.run(test_suite)
Esempio n. 5
0
 def __init__(self, sheet_cases):
     self.do_excel = Do_Excel(GetPath().get_datas_path())
     self.sheet_names = self.do_excel.get_all_sheet_names()  # 获取所有表单名字
     self.sheet_cases = sheet_cases  #指定需要执行的模块,可通过配置项进行修改
Esempio n. 6
0
 def __init__(self):
     self.conf = configparser.ConfigParser()
     self.getpath = GetPath()