Skip to content

Commit f587def

Browse files
committed
[tests][bugfix] Check for result diff existance before accessing to it
1 parent f582849 commit f587def

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/src/python/test_qgsserver.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -502,11 +502,13 @@ def _img_diff_error(self, response, headers, image, max_diff=10, max_size_diff=Q
502502
report, encoded_rendered_file.strip(), tempfile.gettempdir(), image
503503
)
504504

505-
with open(os.path.join(tempfile.gettempdir(), image + "_result_diff.png"), "rb") as diff_file:
506-
encoded_diff_file = base64.b64encode(diff_file.read())
507-
message += "\nDiff:\necho '%s' | base64 -d > %s/%s_result_diff.png" % (
508-
encoded_diff_file.strip(), tempfile.gettempdir(), image
509-
)
505+
# If the failure is in image sizes the diff file will not exists.
506+
if os.path.exists(os.path.join(tempfile.gettempdir(), image + "_result_diff.png")):
507+
with open(os.path.join(tempfile.gettempdir(), image + "_result_diff.png"), "rb") as diff_file:
508+
encoded_diff_file = base64.b64encode(diff_file.read())
509+
message += "\nDiff:\necho '%s' | base64 -d > %s/%s_result_diff.png" % (
510+
encoded_diff_file.strip(), tempfile.gettempdir(), image
511+
)
510512

511513
self.assertTrue(test, message)
512514

0 commit comments

Comments
 (0)