Merge pull request #162 from martinbudden/tests_py

Improved resilience of compare_images.
This commit is contained in:
Chris 2021-03-06 15:58:38 +00:00 committed by GitHub
commit f327df95a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -60,7 +60,8 @@ def compare_images(a, b, c):
with open(log_name, 'w') as output: with open(log_name, 'w') as output:
do_cmd(("magick compare -metric AE -fuzz %d%% %s %s %s" % (fuzz, a, b, c)).split(), output = output) do_cmd(("magick compare -metric AE -fuzz %d%% %s %s %s" % (fuzz, a, b, c)).split(), output = output)
with open(log_name, 'r') as f: with open(log_name, 'r') as f:
pixels = int(float(f.read().strip())) pixels = f.read().strip()
pixels = int(float(pixels if pixels.isnumeric() else -1))
os.remove(log_name) os.remove(log_name)
return pixels return pixels