mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
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:
parent
6bc7a5e35f
commit
8b80853ad7
Binary file not shown.
Before Width: | Height: | Size: 1.3 MiB |
9454
qa/data/cli/basic_test/basic_test.svg
Normal file
9454
qa/data/cli/basic_test/basic_test.svg
Normal file
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 |
4895
qa/data/cli/basic_test/basic_test_nobg_bnw_nods.svg
Normal file
4895
qa/data/cli/basic_test/basic_test_nobg_bnw_nods.svg
Normal file
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 92 KiB |
@ -29,8 +29,8 @@ from typing import List
|
||||
|
||||
|
||||
@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_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", "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.svg", ["--no-background-color", "--exclude-drawing-sheet", "--black-and-white"])
|
||||
])
|
||||
def test_sch_export_svg( kitest,
|
||||
test_file: str,
|
||||
@ -64,11 +64,14 @@ def test_sch_export_svg( kitest,
|
||||
|
||||
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 )
|
||||
|
||||
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",
|
||||
|
@ -120,9 +120,11 @@ def images_are_equal( image1_path: str, image2_path: str ) -> bool:
|
||||
image2 = Image.open( image2_path )
|
||||
|
||||
if image1.size != image2.size:
|
||||
logger.error("Images sizes are different.")
|
||||
return False
|
||||
|
||||
if image1.mode != image2.mode:
|
||||
logger.error("Images modes are different.")
|
||||
return False
|
||||
|
||||
diff = ImageChops.difference( image1, image2 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user