From 8392f468ae3f3f45b05e6f51e5d9c0012dcd5ace Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 23 Sep 2022 09:43:57 -0300 Subject: [PATCH] [Tests] Added some tollerance to img compare for non Debian --- tests/test_plot/test_misc.py | 3 ++- tests/utils/context.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_plot/test_misc.py b/tests/test_plot/test_misc.py index af7be7e8..f8e5404f 100644 --- a/tests/test_plot/test_misc.py +++ b/tests/test_plot/test_misc.py @@ -46,6 +46,7 @@ MK_TARGETS = ['position', 'archive', 'interactive_bom', 'run_erc', '3D', 'kibom_ 'run_drc'] # If we are not running on Debian skip the text part at the top of diff PDFs OFFSET_Y = '0' if os.path.isfile('/etc/debian_version') else '80' +DIFF_TOL = 0 if os.path.isfile('/etc/debian_version') else 1200 def test_skip_pre_and_outputs(test_dir): @@ -1277,7 +1278,7 @@ def test_diff_file_1(test_dir): yaml = 'diff_file_'+('k5' if context.ki5() else 'k6') ctx = context.TestContext(test_dir, prj, yaml) ctx.run() - ctx.compare_pdf(prj+'-diff_pcb.pdf', reference='light_control-diff_pcb.pdf', off_y=OFFSET_Y) + ctx.compare_pdf(prj+'-diff_pcb.pdf', reference='light_control-diff_pcb.pdf', off_y=OFFSET_Y, tol=DIFF_TOL) ctx.clean_up(keep_project=True) diff --git a/tests/utils/context.py b/tests/utils/context.py index b551b828..811ea249 100644 --- a/tests/utils/context.py +++ b/tests/utils/context.py @@ -520,7 +520,7 @@ class TestContext(object): os.remove(png_image) assert ae <= tol - def compare_pdf(self, gen, reference=None, diff='diff-{}.png', height='87%', off_y='0'): + def compare_pdf(self, gen, reference=None, diff='diff-{}.png', height='87%', off_y='0', tol=0): """ For multi-page PDFs """ if reference is None: reference = gen @@ -545,7 +545,7 @@ class TestContext(object): # Compare each page for page in range(len(ref_pages)): self.compare_image('gen-'+str(page)+'.png', 'ref-'+str(page)+'.png', diff.format(page), ref_out_dir=True, - height=height, off_y=off_y) + height=height, off_y=off_y, tol=tol) def compare_txt(self, text, reference=None, diff='diff.txt'): if reference is None: