Skip to content
Permalink
Browse files

[tests][bugfix] Check for result diff existance before accessing to it

  • Loading branch information
elpaso committed Nov 4, 2016
1 parent f582849 commit f587defde24595ad85a5ad08c19f915eebdd3658
Showing with 7 additions and 5 deletions.
  1. +7 −5 tests/src/python/test_qgsserver.py
@@ -502,11 +502,13 @@ def _img_diff_error(self, response, headers, image, max_diff=10, max_size_diff=Q
report, encoded_rendered_file.strip(), tempfile.gettempdir(), image
)

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

self.assertTrue(test, message)

0 comments on commit f587def

Please sign in to comment.
You can’t perform that action at this time.