Commits

Luke Macken committed ec0e731

Fix the unit tests for Python 2.7

  • Participants
  • Parent commits d95237b

Comments (0)

Files changed (2)

File tests/test_htmlfill.py

 
 try:
     import xml.etree.ElementTree as ET
+    from xml.etree.ElementTree import ParseError
 except ImportError:
     import elementtree.ElementTree as ET
 
     try:
         output_xml = ET.XML(output)
         expected_xml = ET.XML(expected)
-    except ExpatError:
+    except (ParseError, ExpatError):
+        # On python-2.7, this is a ParseError
+        # On python-2.6 or less it's an ExpatError
         comp = output.strip() == expected.strip()
     else:
         comp = xml_compare(output_xml, expected_xml, reporter)

File tests/test_htmlgen.py

 
 
 def test_comment():
-    assert str(html.comment('test')) == '<!-- test -->'
-    assert (str(html.comment(uni_value))
-            == '<!-- %s -->' % uni_value.encode('utf-8'))
-    assert str(html.comment('test')('this')) == '<!-- testthis -->'
+    # Note: spaces vs no spaces is a python-2.7+ vs python-2.6 or less
+    # difference
+    assert str(html.comment('test')) in ('<!--test-->', '<!-- test -->')
+    assert (str(html.comment(uni_value)) in
+        ('<!--%s-->' % uni_value.encode('utf-8'),
+            '<!-- %s -->' % uni_value.encode('utf-8')))
+    assert str(html.comment('test')('this')) in ('<!--testthis-->',
+        '<!-- testthis -->')
 
 
 def test_none():