在根目录下添加配置文件settings.py文件,用于存放项目中可一些配置化的参数
"""
配置文件
"""
import os
# 项目根目录
# 配置文件的绝对路径
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# 项目的HOST
PROJECT_HOST = 'http://www.XXX.com/XXX'
# 接口信息
INTERFACE = {
'register': '/XXX/XXX',
'login': '/XXX/XXX',
}
# 鉴权方式请求头
CUSTOM_HEADERS = {
'v1': {'X-XXX-XXX-Type': 'XXX.v1'},
'v2': {'X-XXX-XXX-Type': 'XXX.v2'},
'v3': {'X-XXX-XXX-Type': 'XXX.v3'},
}
# 测试数据配置
# 测试用例路径
TEST_CASE_DIR = os.path.join(BASE_DIR, 'testcases')
# 测试数据文件路径
TEST_DATA_FILE = os.path.join(BASE_DIR, 'testdata', 'testcases.xlsx')
# 日志配置
LOG_CONFIG = {
'name': 'WJ-test',
'file': os.path.join(BASE_DIR, 'log', 'WJ-test.log'),
'fmt': '%(levelname)s %(asctime)s [%(filename)s-->line:%(lineno)d]:%(message)s',
'debug': True
}
# 数据库配置
DATABASE_CONFIG = {
'host': '数据库链接地址',
'user': '账号',
'password': '密码',
'db': '库名',
'charset': 'utf8',
'autocommit': True, # 解决了可重复读的问题
}
# 测试报告配置
TEST_REPORT_CONFIG = {
'file': 'WJ-report.html',
'report_dir': os.path.join(BASE_DIR, 'report'),
'title': 'wj-test-report',
'description': None,
'tester': 'WJ',
'type_': 'htr' # htr--->HTMLTestRunner # bf--->BeautifulReport
}
# 配置allure结果路径
ALLURE_RESULT_DIR = os.path.join(BASE_DIR, 'allure-result')
TEST_NG_RESULT_FILE = os.path.join(BASE_DIR, 'testng_result', 'testng-results.xml')
# 邮件地址
EMAIL = {
'mail_host': 'smtp.163.com',
'mail_user': 'XXXXXX@163.com',
'mail_pass': '*********',
'mail_port': 25,
'sender': 'xxx@163.com',
'receiver': 'xxxx@qq.com/xxxx@qq.com',
'subject': 'python',
'content': "All interface test has been complited\nplease read the report file about the detile of result in the attachment.",
'testuser': 'Someone',
'on_off': 1,
}