Sfoglia il codice sorgente

Add more detail to fortune test fails

Alex Schneider 11 anni fa
parent
commit
09dff87df7
1 ha cambiato i file con 8 aggiunte e 2 eliminazioni
  1. 8 2
      toolset/benchmark/fortune_html_parser.py

+ 8 - 2
toolset/benchmark/fortune_html_parser.py

@@ -1,5 +1,6 @@
 # -*- coding: utf-8
 from HTMLParser import HTMLParser
+from difflib import unified_diff
 
 class FortuneHTMLParser(HTMLParser):
   body = []
@@ -107,5 +108,10 @@ class FortuneHTMLParser(HTMLParser):
   # is valid against our known "fortune" spec.
   # The parsed data in 'body' is joined on empty strings
   # and checked for equality against our spec.
-  def isValidFortune(self):
-    return self.valid == ''.join(self.body)
+  def isValidFortune(self, out):
+    body = ''.join(self.body)
+    diff = self.valid == body
+    if not diff:
+      out.write("Fortune invalid. Diff following:\n")
+      out.write(''.join(unified_diff(self.valid, body, fromfile="Valid", tofile="Output")) + '\n')
+    return diff