excel2pic/tests/test_border.py

37 lines
1.1 KiB
Python

import pytest
import io
import os
from core.renderer import ExcelRenderer
from PIL import Image
# Use the file provided by the user for reproduction
TEST_FILE_PATH = "tests/kshj_gt1767081783800.xlsx"
@pytest.mark.skipif(not os.path.exists(TEST_FILE_PATH), reason="Test file not found")
def test_border_rendering_real_file():
"""
Test rendering with a real file that has border issues.
This test will generate an output image for visual inspection.
"""
with open(TEST_FILE_PATH, "rb") as f:
content = f.read()
renderer = ExcelRenderer(content)
try:
# Render with high DPI scale
img_bytes = renderer.render_to_bytes(scale=3)
# Save for visual inspection
output_path = "tests/test_output_border.png"
with open(output_path, "wb") as f_out:
f_out.write(img_bytes)
print(f"Generated test image at: {os.path.abspath(output_path)}")
assert isinstance(img_bytes, bytes)
assert len(img_bytes) > 0
except Exception as e:
pytest.fail(f"Rendering failed: {e}")