예제 #1
0
 def setup_class(cls):
     # 初始化用例参数,将全局变量替换成配置文件中得变量
     cls.result = {"result": True}
     # 更新配置文件中的token
     cls.token = token.Token()
     cls.token.save_token()
     cls.log = log.MyLog()
     cls.Assert = assert_pro.Assertions()
예제 #2
0
 def setup_class(cls):
     """
     初始化用例参数,将全局变量替换成配置文件中得变量
     :return:
     """
     cls.result = {"result": True}
     cls.token = token.Token()
     cls.token.save_token()
     cls.log = log.MyLog()
     cls.Assert = assert_pro.Assertions()
예제 #3
0
 def __init__(self):
     self.config = conf.Config()
     self.log = log.MyLog()
     self.data = conf_relevance.ConfRelevance(
         CONF_PATH, "test_data").get_relevance_conf()
     self.headers = {
         "User-Agent":
         "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
         "Content-Type": "application/json",
         "X-Auth-Token": self.config.token
     }
예제 #4
0
 def setup_class(cls):
     # 初始化用例参数,将全局变量替换成配置文件中得变量
     # cls.rel = ini_rel
     with allure.step("初始化环境变量"):
         cls.log = log.MyLog()
         cls.Assert = assert_pro.Assertions()
         cls.log.info("设置project_token_name为amdin")
         conf = Config()
         conf.set_conf("test_data", "project_token_name", "admin")
         cls.result = {"result": True}
         # 更新配置文件中的token
         cls.token = token.Token()
         cls.token.save_token()
예제 #5
0
    def __init__(self):
        self.config = conf.Config()
        self.log = log.MyLog()
        self.relevance = conf_relevance.ConfRelevance(
            CONF_PATH, "test_data").get_relevance_conf()
        self.headers = {
            "User-Agent":
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
            "Content-Type": "application/json",
            "X-Auth-Token": "${token_id}$"
        }

        self.address = {
            "address":
            "/v3/projects/${project_id}$/users/${admin_id}$/roles/${admin_role_id}$"
        }
예제 #6
0
파일: conf.py 프로젝트: woozs/api_auto_test
    def __init__(self):
        """
        初始化
        """
        self.config = ConfigParser()
        self.log = log.MyLog()
        self.conf_path = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'cfg.ini')
        self.xml_report_path = Config.path_dir + '/report/xml'
        self.html_report_path = Config.path_dir + '/report/html'

        if not os.path.exists(self.conf_path):
            raise FileNotFoundError("请确保配置文件存在!")

        self.config.read(self.conf_path, encoding='utf-8')

        self.tester = self.get_conf(Config.TITLE_ENV, Config.VALUE_TESTER)
        self.environment = self.get_conf(Config.TITLE_ENV,
                                         Config.VALUE_ENVIRONMENT)
        self.versionCode = self.get_conf(Config.TITLE_ENV,
                                         Config.VALUE_VERSION_CODE)
        self.host = self.get_conf(Config.TITLE_ENV, Config.VALUE_HOST)
        self.loginInfo = self.get_conf(Config.TITLE_ENV,
                                       Config.VALUE_LOGIN_INFO)

        self.smtpserver = self.get_conf(Config.TITLE_EMAIL,
                                        Config.VALUE_SMTP_SERVER)
        self.sender = self.get_conf(Config.TITLE_EMAIL, Config.VALUE_SENDER)
        self.receiver = self.get_conf(Config.TITLE_EMAIL,
                                      Config.VALUE_RECEIVER)
        self.username = self.get_conf(Config.TITLE_EMAIL,
                                      Config.VALUE_USERNAME)
        self.password = self.get_conf(Config.TITLE_EMAIL,
                                      Config.VALUE_PASSWORD)
        self.send = self.get_conf(Config.TITLE_EMAIL, Config.VALUE_SEND)
        self.token = self.get_conf(Config.TITLE_TEST_DATA, Config.VALUE_TOKEN)
예제 #7
0
 def __init__(self):
     self.config = conf.Config()
     self.log = log.MyLog()
     self.relevance = conf_relevance.ConfRelevance(
         CONF_PATH, "test_data").get_relevance_conf()
예제 #8
0
 def __init__(self):
     self.log = log.MyLog()
예제 #9
0
 def __init__(self):
     self.config = Config()
     self.log = log.MyLog()
예제 #10
0
파일: run.py 프로젝트: woozs/api_auto_test
import pytest

from common import log
from common import shell
from conf import conf
from common import send_email
from unit import initialize_env


failureException = AssertionError

if __name__ == '__main__':

    conf = conf.Config()
    log = log.MyLog()
    log.info('初始化配置文件, path=' + conf.conf_path)
    shell = shell.Shell()
    xml_report_path = conf.xml_report_path
    html_report_path = conf.html_report_path

    # 初始化allure环境配置文件environment.xml
    initialize_env.Init_Env().init()

    # 定义测试集
    args = ['-s', '-q', '--alluredir', xml_report_path]
    # args = ['-s', '-q', '--alluredir', "H:\\api_auto_test\\report\xml"]
    pytest.main(args)
    cmd = 'allure generate %s -o %s  --clean' % (
        xml_report_path, html_report_path)
    log.info("执行allure,生成测试报告")