Exemple #1
0
 def __init__(self):
     conf = configparser.ConfigParser()
     path = os.path.dirname(__file__)
     conf.read(path + '..\..\..\config\config.ini', encoding='utf-8')
     self.logger = logs.Logs().logger
     self.r = RequestsUtil()
     self.urls = conf.get('host', 'url')
Exemple #2
0
 def __init__(self):
     config = configparser.ConfigParser()
     path = os.path.dirname(__file__)
     config.read(path + '\..\..\config\config.ini', encoding='utf-8')
     self.logger = logs.Logs().logger
     self.r = RequestsUtil()
     self.urls = config.get('host', 'url')
     self.headers = json.loads(config.get('headers', 'token'))
     self.Mydb = MYdb()
Exemple #3
0
 def setUpClass(cls):
     cls.logger = logs.Logs().logger
     conf = configparser.ConfigParser()
     '''读取配置文件'''
     path = os.path.join(os.getcwd(), '..\config\config.ini')
     conf.read(path, encoding='utf-8')  # 文件路径
     cls.licenseno = conf.get("baojia", "licenseno")  # 获取配置文件指定的值
     cls.city = conf.get("baojia", "city")
     cls.xinzeng = InterfaceQuote()
     cls.chudan = ChudanZhanbai()
     cls.customer = CustomerList()
     cls.headers = json.loads(conf.get('headers', 'token'))
     cls.urls = conf.get('host', 'url')
     cls.work = WorkPanel()
     cls.today_Ymd = datetime.datetime.now().strftime('%Y-%m-%d')
Exemple #4
0
    result = unittest.defaultTestLoader.discover(path + "/case",
                                                 pattern="test_case.py",
                                                 top_level_dir=None)
    return result


def file_dir(path):
    is_file = os.path.isdir(path)
    if is_file:
        pass
    else:
        os.mkdir(path)


if __name__ == '__main__':
    logger = logs.Logs('run_case').logger
    logger.info('登录账户获取touken')
    Headers.token_update_config('wanyuanhao')
    times = datetime.datetime.now()
    time = times.strftime('%Y-%m-%d')
    # wb写入内容,没有文件会创建,有文件会覆盖文件内容
    path = os.path.dirname(__file__)
    file_dir(path + "./test_report")
    report_path = open(f"./test_report/{time}result.html", 'wb')
    runner = HTMLTestRunner.HTMLTestRunner(stream=report_path,
                                           title=u"自动化测试报告(详情请看附件)",
                                           description="执行结果",
                                           verbosity=2)
    ss = runner.run(run_test_case())
    # 关闭报告
    report_path.close()
Exemple #5
0
 def __init__(self):
     self.logger = logs.Logs().logger
Exemple #6
0
from util.request_util import RequestsUtil
import configparser
import os, json
from logs import logs

r = RequestsUtil()
# 找到配置文件路径
path = os.path.dirname(__file__)
# 把读取配置的类包赋值
configs = configparser.ConfigParser()
# 读取配置文件
configs.read(path + '\config.ini', encoding='utf-8')
# 读取配置文件的指定配置
users = configs.get('host', 'user')
urls = configs.get('host', 'url')
logger = logs.Logs().logger


class Headers:
    # 获取到的token更新到config文件
    @classmethod
    def token_update_config(self, user):
        try:
            # url = urls + '/identity/connect/token'  # 老接口
            # data = {'grant_type': 'password',
            #         'username': user,
            #         'password': '******',
            #         'scope': 'employee_center car_business smart_car_mgts',
            #         'client_id': 'bot',
            #         'client_secret': 'secret'}
            url = urls + '/identity/api/v1/Login/LoginApi2'