1
0
Files
PPTX/tests/fixtures/create_test_images.py
lanyuanxiaoyao ab2510a400 test: add comprehensive pytest test suite
Add complete test infrastructure for yaml2pptx project with 245+ tests
covering unit, integration, and end-to-end scenarios.

Test structure:
- Unit tests: elements, template system, validators, loaders, utils
- Integration tests: presentation and rendering flows
- E2E tests: CLI commands (convert, check, preview)

Key features:
- PptxFileValidator for Level 2 PPTX validation (file structure,
  element count, content matching, position tolerance)
- Comprehensive fixtures for test data consistency
- Mock-based testing for external dependencies
- Test images generated with PIL/Pillow
- Boundary case coverage for edge scenarios

Dependencies added:
- pytest, pytest-cov, pytest-mock
- pillow (for test image generation)

Documentation updated:
- README.md: test running instructions
- README_DEV.md: test development guide

Co-authored-by: OpenSpec change: add-comprehensive-tests
2026-03-02 23:11:34 +08:00

35 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
创建测试图片的辅助脚本
"""
from PIL import Image, ImageDraw
from pathlib import Path
# 确保目录存在
images_dir = Path(__file__).parent.parent / "fixtures" / "images"
images_dir.mkdir(exist_ok=True)
# 创建一个简单的红色图片
img = Image.new('RGB', (100, 100), color='red')
img.save(images_dir / "test_image.png")
# 创建一个较大的图片
large_img = Image.new('RGB', (800, 600), color='blue')
large_img.save(images_dir / "large_image.png")
# 创建一个带有透明度的图片PNG
transparent_img = Image.new('RGBA', (100, 100), (255, 0, 0, 128))
transparent_img.save(images_dir / "transparent_image.png")
# 创建一个小图片
small_img = Image.new('RGB', (50, 50), color='green')
small_img.save(images_dir / "small_image.png")
# 创建一个带文字的图片
text_img = Image.new('RGB', (200, 100), color='white')
draw = ImageDraw.Draw(text_img)
draw.text((10, 30), "Test Image", fill='black')
text_img.save(images_dir / "text_image.png")
print(f"Created test images in {images_dir}")