Made the image comparisson more fuzzy.

This commit is contained in:
Salvador E. Tropea 2020-09-04 18:51:05 -03:00
parent d09400d49d
commit a59870808d
2 changed files with 8 additions and 5 deletions

View File

@ -105,7 +105,10 @@ def test_pcbdraw_variant_1():
# Check all outputs are there
fname = prj+'-top.png'
ctx.expect_out_file(fname)
ctx.compare_image(fname)
# We use 30% because different versions of the tools are generating large differences
# in the borders. With 30% these differences are removed and we still detect is a
# components was removed.
ctx.compare_image(fname, fuzz='30%')
ctx.clean_up()
@ -116,7 +119,7 @@ def test_pcbdraw_variant_2():
# Check all outputs are there
fname = prj+'-top-C1.png'
ctx.expect_out_file(fname)
ctx.compare_image(fname)
ctx.compare_image(fname, fuzz='30%')
ctx.clean_up()
@ -127,6 +130,6 @@ def test_pcbdraw_variant_3():
# Check all outputs are there
fname = prj+'-top.png'
ctx.expect_out_file(fname)
ctx.compare_image(fname)
ctx.compare_image(fname, fuzz='30%')
assert ctx.search_err("Ambiguous list of components to show .?none.? vs variant/filter")
ctx.clean_up()

View File

@ -310,7 +310,7 @@ class TestContext(object):
logging.debug(msg+' OK')
# logging.debug(' '+m.group(0))
def compare_image(self, image, reference=None, diff='diff.png', ref_out_dir=False):
def compare_image(self, image, reference=None, diff='diff.png', ref_out_dir=False, fuzz='5%'):
""" For images and single page PDFs """
if reference is None:
reference = image
@ -320,7 +320,7 @@ class TestContext(object):
reference = os.path.join(REF_DIR, reference)
cmd = ['compare',
# Tolerate 5 % error in color
'-fuzz', '5%',
'-fuzz', fuzz,
# Count how many pixels differ
'-metric', 'AE',
self.get_out_path(image),