Files
sbackup/tests/conftest.py
T
xiatianxuan 8f2bcdf8fa v2.0.0: 多目标备份 + S3云存储 + 完整性校验 + 9语言国际化
feat: v2.0.0 — 多目标备份 + S3云存储 + 审计日志 + 9语言国际化
2026-06-20 14:01:43 +08:00

19 lines
364 B
Python

"""全局测试配置:确保工作目录始终有效"""
import os
import tempfile
import pytest
# 启动时保存一个安全的工作目录
_SAFE_CWD = os.getcwd()
@pytest.fixture(autouse=True)
def _restore_cwd():
"""每个测试前后确保 cwd 有效"""
yield
try:
os.getcwd()
except FileNotFoundError:
os.chdir(_SAFE_CWD)