Coverage for tests / conftest.py: 75%
12 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-29 02:55 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-29 02:55 +0800
1"""
2pytest 配置文件
4提供测试 fixtures 和通用配置。
5"""
6import pytest
7import tempfile
8from pathlib import Path
11@pytest.fixture
12def temp_dir():
13 """临时目录 fixture,测试结束后自动清理"""
14 with tempfile.TemporaryDirectory() as tmpdir:
15 yield Path(tmpdir)
18@pytest.fixture
19def temp_file(temp_dir):
20 """临时文件 fixture"""
21 file_path = temp_dir / "test.txt"
22 file_path.write_text("hello world", encoding="utf-8")
23 return file_path