Skip to content
Permalink
Browse files

[tests][bugfix] Skip diff image if it does not exists

  • Loading branch information
elpaso committed Nov 3, 2016
1 parent 4329128 commit 4fe9a8be777e0dfd625b86fdbb0df8e784e81336
Showing with 7 additions and 5 deletions.
  1. +7 −5 tests/src/python/test_qgsserver.py
@@ -459,11 +459,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 4fe9a8b

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