Skip to content

Commit

Permalink
Better failure messages for assertScreenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
bfirsh committed Oct 7, 2011
1 parent e26e9b5 commit 079a718
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion needle/cases.py
Expand Up @@ -69,7 +69,13 @@ def assertScreenshot(self, element, name, threshold=0.1):
else: else:
image = Image.open(filename) image = Image.open(filename)
diff = ImageDiff(element.get_screenshot(), image) 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))








Expand Down

0 comments on commit 079a718

Please sign in to comment.