refactor: 优化日志系统及自动化备份机制
- 替换 loguru 为原生 logging 库(与pytest兼容性更好)。 - 更新 pytest.ini 统一配置日志格式和基础命令。 - 优化 main.py 增加测试后的日志自动备份与定期清理功能。 - 新增 settings.py 实现配置解耦 - 更新 .gitignore
This commit is contained in:
40
core/settings.py
Normal file
40
core/settings.py
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
|
||||
"""
|
||||
@author: CNWei,ChenWei
|
||||
@Software: PyCharm
|
||||
@contact: t6g888@163.com,chenwei@zygj.com
|
||||
@file: settings
|
||||
@date: 2026/1/19 16:54
|
||||
@desc:
|
||||
"""
|
||||
import os
|
||||
# core/settings.py
|
||||
from pathlib import Path
|
||||
|
||||
# 项目根目录 (core 的上一级)
|
||||
BASE_DIR = Path(__file__).parent.parent
|
||||
|
||||
# --- 目录配置 ---
|
||||
OUTPUT_DIR = BASE_DIR / "outputs"
|
||||
LOG_DIR = OUTPUT_DIR / "logs"
|
||||
LOG_BACKUP_DIR = LOG_DIR / "backups"
|
||||
ALLURE_TEMP = BASE_DIR / "temp"
|
||||
REPORT_DIR = BASE_DIR / "report"
|
||||
|
||||
# 确保必要的目录存在
|
||||
for folder in [LOG_DIR, LOG_BACKUP_DIR, ALLURE_TEMP]:
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# --- 文件路径 ---
|
||||
LOG_SOURCE = LOG_DIR / "pytest.log"
|
||||
|
||||
# --- 业务常量 (可选) ---
|
||||
IMPLICIT_WAIT = 10
|
||||
APPIUM_SERVER = "http://127.0.0.1:4723"
|
||||
# --- 核心配置 ---
|
||||
APPIUM_HOST = "127.0.0.1"
|
||||
APPIUM_PORT = 4723
|
||||
|
||||
|
||||
Reference in New Issue
Block a user