Coverage for tests/conftest.py: 75%

1"""

2 pytest 配置文件

3

4提供测试 fixtures 和通用配置。

5"""

6 import pytest

7 import tempfile

8 from pathlib import Path

9

10

11@pytest.fixture

12 def temp_dir():

13 """临时目录 fixture，测试结束后自动清理"""

14 with tempfile.TemporaryDirectory() as tmpdir:

15 yield Path(tmpdir)

16

17

18@pytest.fixture

19 def 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