1
0
Files
PPTX/openspec/changes/archive/2026-03-03-fix-failing-tests/proposal.md
lanyuanxiaoyao 22614d6f55 fix: 修复 7 个失败测试和 1 个错误测试
- 修复 conftest_pptx.py 中元素类型检测:使用 has_text_frame 替代不存在的 MSO_SHAPE.TEXT_BOX
- 修复 test_presentation.py 中 3 个测试:使用对象属性访问替代字典访问
- 修复 unit/test_presentation.py 中路径比较问题
- 添加缺失的 mock_template_class fixture

测试通过率: 316/316 (100%)
代码覆盖率: 94%
2026-03-03 01:25:36 +08:00

1.9 KiB

修复失败的测试

Why

当前项目有 7 个测试失败和 1 个测试错误,导致测试通过率从 100% 降至 97.5%。这些问题主要是由于:

  1. 测试代码与实际 API 行为不一致
  2. python-pptx 库版本变化导致的 API 差异
  3. Windows 平台路径处理差异
  4. 测试 fixture 定义缺失

如果不修复这些问题,将影响持续集成的可靠性,并阻碍后续功能开发。

What Changes

测试修复

  • 修复 test_render_slide_with_template - 调整测试以适应返回的元素对象
  • 修复 test_render_slide_with_variables - 调整测试以适应返回的元素对象
  • 修复 test_render_direct_elements - 调整测试以适应返回的元素对象
  • 修复 test_image_element_rendering - 使用正确的枚举或替代方法检测文本框
  • 修复 test_shape_element_rendering - 使用正确的枚举或替代方法检测形状
  • 修复 test_table_element_rendering - 使用正确的枚举或替代方法检测表格
  • 修复 test_init_with_templates_dir - 统一路径类型比较
  • 修复 test_render_slide_with_template_merges_background - 添加缺失的 fixture

代码改进

  • tests/conftest_pptx.py 中改进元素类型检测逻辑
  • 添加更健壮的 python-pptx 版本兼容性处理

Capabilities

New Capabilities

  • test-fix-framework: 建立测试修复的标准框架,确保未来 API 变更时测试能同步更新

Modified Capabilities

  • 无(现有功能的测试修复,不改变功能需求)

Impact

受影响代码

  • tests/integration/test_presentation.py - 3 个失败测试
  • tests/integration/test_rendering_flow.py - 3 个失败测试
  • tests/unit/test_presentation.py - 1 个失败测试 + 1 个错误
  • tests/conftest_pptx.py - 辅助验证函数

测试影响

  • 修复后测试通过率: 100% (316/316)
  • 代码覆盖率: 维持 94%

依赖影响

  • 无新增依赖
  • 保持与 python-pptx 现有版本的兼容性