QA: Store SVGs, not PNGs

Different platforms/versions can result in very slight differences
when converting SVGs to PNGs for diffing them.
This commit is contained in:
Jon Evans 2025-06-14 16:56:47 -04:00
parent 6bc7a5e35f
commit 8b80853ad7
6 changed files with 14359 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 744 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 92 KiB

View File

@ -29,8 +29,8 @@ from typing import List
@pytest.mark.parametrize("test_file,output_dir,compare_fn,cli_args", @pytest.mark.parametrize("test_file,output_dir,compare_fn,cli_args",
[("cli/basic_test/basic_test.kicad_sch", "basic_test", "cli/basic_test/basic_test.png", []), [("cli/basic_test/basic_test.kicad_sch", "basic_test", "cli/basic_test/basic_test.svg", []),
("cli/basic_test/basic_test.kicad_sch", "basic_test_nobg_bnw_nods", "cli/basic_test/basic_test_nobg_bnw_nods.png", ["--no-background-color", "--exclude-drawing-sheet", "--black-and-white"]) ("cli/basic_test/basic_test.kicad_sch", "basic_test_nobg_bnw_nods", "cli/basic_test/basic_test_nobg_bnw_nods.svg", ["--no-background-color", "--exclude-drawing-sheet", "--black-and-white"])
]) ])
def test_sch_export_svg( kitest, def test_sch_export_svg( kitest,
test_file: str, test_file: str,
@ -64,11 +64,14 @@ def test_sch_export_svg( kitest,
png_converted_from_svg_path = output_svg_path.with_suffix( '.png' ) png_converted_from_svg_path = output_svg_path.with_suffix( '.png' )
compare_file_path = kitest.get_data_file_path( compare_fn )
cairosvg.svg2png( url=str( output_svg_path ), write_to=str( png_converted_from_svg_path ), dpi=1200 ) cairosvg.svg2png( url=str( output_svg_path ), write_to=str( png_converted_from_svg_path ), dpi=1200 )
assert utils.images_are_equal( png_converted_from_svg_path, compare_file_path ) compare_file_path = kitest.get_data_file_path( compare_fn )
compare_stem = f"orig_{output_dir}"
compare_png_converted_from_svg_path = output_svg_path.with_suffix( '.png' ).with_stem(compare_stem)
cairosvg.svg2png( url=str( compare_file_path ), write_to=str( compare_png_converted_from_svg_path ), dpi=1200 )
assert utils.images_are_equal( png_converted_from_svg_path, compare_png_converted_from_svg_path )
@pytest.mark.parametrize("test_file,output_fn,line_skip_count,skip_compare,cli_args", @pytest.mark.parametrize("test_file,output_fn,line_skip_count,skip_compare,cli_args",

View File

@ -120,9 +120,11 @@ def images_are_equal( image1_path: str, image2_path: str ) -> bool:
image2 = Image.open( image2_path ) image2 = Image.open( image2_path )
if image1.size != image2.size: if image1.size != image2.size:
logger.error("Images sizes are different.")
return False return False
if image1.mode != image2.mode: if image1.mode != image2.mode:
logger.error("Images modes are different.")
return False return False
diff = ImageChops.difference( image1, image2 ) diff = ImageChops.difference( image1, image2 )