"""Reader 测试专用 fixtures。""" import pytest from pathlib import Path # 静态测试文件目录 FIXTURES_DIR = Path(__file__).parent / "fixtures" @pytest.fixture def doc_fixture_path(): """返回 DOC 静态测试文件目录""" return FIXTURES_DIR / "doc" @pytest.fixture def xls_fixture_path(): """返回 XLS 静态测试文件目录""" return FIXTURES_DIR / "xls" @pytest.fixture def ppt_fixture_path(): """返回 PPT 静态测试文件目录""" return FIXTURES_DIR / "ppt" def _get_static_file_path(fixture_dir, filename): """获取静态文件路径,不存在时跳过测试""" file_path = fixture_dir / filename if not file_path.exists(): pytest.skip(f"静态测试文件不存在: {file_path}") return str(file_path) @pytest.fixture def simple_doc_path(doc_fixture_path): """返回简单 DOC 测试文件路径""" return _get_static_file_path(doc_fixture_path, "simple.doc") @pytest.fixture def with_headings_doc_path(doc_fixture_path): """返回带标题的 DOC 测试文件路径""" return _get_static_file_path(doc_fixture_path, "with_headings.doc") @pytest.fixture def with_table_doc_path(doc_fixture_path): """返回带表格的 DOC 测试文件路径""" return _get_static_file_path(doc_fixture_path, "with_table.doc") @pytest.fixture def simple_xls_path(xls_fixture_path): """返回简单 XLS 测试文件路径""" return _get_static_file_path(xls_fixture_path, "simple.xls") @pytest.fixture def multiple_sheets_xls_path(xls_fixture_path): """返回多工作表 XLS 测试文件路径""" return _get_static_file_path(xls_fixture_path, "multiple_sheets.xls") @pytest.fixture def with_formulas_xls_path(xls_fixture_path): """返回带公式 XLS 测试文件路径""" return _get_static_file_path(xls_fixture_path, "with_formulas.xls") @pytest.fixture def simple_ppt_path(ppt_fixture_path): """返回简单 PPT 测试文件路径""" return _get_static_file_path(ppt_fixture_path, "simple.ppt") @pytest.fixture def multiple_slides_ppt_path(ppt_fixture_path): """返回多幻灯片 PPT 测试文件路径""" return _get_static_file_path(ppt_fixture_path, "multiple_slides.ppt") @pytest.fixture def with_images_ppt_path(ppt_fixture_path): """返回带图片 PPT 测试文件路径""" return _get_static_file_path(ppt_fixture_path, "with_images.ppt")