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_font_color_rendering_real_file(): """ Test rendering with a real file that has font color 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 the first sheet (or specific sheet if known, default to active) img_bytes = renderer.render_to_bytes() # Save for visual inspection output_path = "tests/test_output_font_color.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}")