Permalink
Browse files

Better failure messages for assertScreenshot

  • Loading branch information...
1 parent e26e9b5 commit 079a718ce8115679c224e7477c13529c6c3d8e10 @bfirsh bfirsh committed Oct 7, 2011
Showing with 7 additions and 1 deletion.
  1. +7 −1 needle/cases.py
View
@@ -69,7 +69,13 @@ def assertScreenshot(self, element, name, threshold=0.1):
else:
image = Image.open(filename)
diff = ImageDiff(element.get_screenshot(), image)
- self.assertAlmostEqual(diff.get_distance(), 0, delta=threshold)
+ distance = abs(diff.get_distance())
+ if distance > threshold:
+ raise AssertionError("The saved screenshot for '%s' did not match "
+ "the screenshot captured (by a distance of %.2f)"
+ % (name, distance))
+
+

0 comments on commit 079a718

Please sign in to comment.