[Lxml-checkins] r43954 - lxml/branch/html/src/lxml

ianb at codespeak.net ianb at codespeak.net
Fri Jun 1 06:18:44 CEST 2007


Author: ianb
Date: Fri Jun  1 06:18:43 2007
New Revision: 43954

Modified:
   lxml/branch/html/src/lxml/doctestcompare.py
Log:
Change the diff output a bit; only parse if both got *and* want look like HTML/XML

Modified: lxml/branch/html/src/lxml/doctestcompare.py
==============================================================================
--- lxml/branch/html/src/lxml/doctestcompare.py	(original)
+++ lxml/branch/html/src/lxml/doctestcompare.py	Fri Jun  1 06:18:43 2007
@@ -78,9 +78,11 @@
             parser = HTML
         elif PARSE_XML & optionflags:
             parser = etree.XML
-        elif want.strip().lower().startswith('<html'):
+        elif (want.strip().lower().startswith('<html')
+              and got.strip().startswith('<html')):
             parser = HTML
-        elif want.strip().startswith('<'):
+        elif (want.strip().startswith('<')
+              and got.strip().startswith('<')):
             parser = self.get_default_parser()
         return parser
 
@@ -260,7 +262,7 @@
 
     def collect_diff_tag(self, want, got):
         if want.tag != got.tag and want.tag != 'any':
-            tag = '%s (not %s)' % (got.tag, want.tag)
+            tag = '%s (got: %s)' % (want.tag, got.tag)
         else:
             tag = got.tag
         attrs = []
@@ -287,7 +289,7 @@
 
     def collect_diff_end_tag(self, want, got):
         if want.tag != got.tag:
-            tag = '%s (not %s)' % (got.tag, want.tag)
+            tag = '%s (got: %s)' % (want.tag, got.tag)
         else:
             tag = got.tag
         return '</%s>' % tag
@@ -297,7 +299,7 @@
             if not got:
                 return ''
             return self.format_text(got, strip)
-        text = '%s (not %s)' % (got, want)
+        text = '%s (got: %s)' % (want, got)
         return self.format_text(text, strip)
 
 class LHTMLOutputChecker(LXMLOutputChecker):


More information about the lxml-checkins mailing list