]> git.sommitrealweird.co.uk Git - rss2maildir.git/commitdiff
* Add unit test for some of the badly formed lists that we get after the
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Mon, 31 Dec 2007 02:56:28 +0000 (02:56 +0000)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Mon, 31 Dec 2007 02:56:28 +0000 (02:56 +0000)
  feedparser "sanitizer" has a word with the HTML (currently fails)

tests/expected/unorderedlist-badlyformed.txt [new file with mode: 0644]
tests/html/unorderedlist-badlyformed.html [new file with mode: 0644]
tests/unittests/UnorderedListTests.py [changed mode: 0644->0755]

diff --git a/tests/expected/unorderedlist-badlyformed.txt b/tests/expected/unorderedlist-badlyformed.txt
new file mode 100644 (file)
index 0000000..49d47f6
--- /dev/null
@@ -0,0 +1,3 @@
+  * This is an item
+  * And a second
+  * And a third
diff --git a/tests/html/unorderedlist-badlyformed.html b/tests/html/unorderedlist-badlyformed.html
new file mode 100644 (file)
index 0000000..b37ec7f
--- /dev/null
@@ -0,0 +1,6 @@
+<ul>
+    <li>This is an item
+    <li>And a second
+    <li>And a third
+    </li></li></li>
+</ul>
old mode 100644 (file)
new mode 100755 (executable)
index af09b7c..4d2c393
@@ -25,5 +25,23 @@ class UnorderedListTests(unittest.TestCase):
         output = parser.gettext()
         self.assertEqual(output, expectedoutput)
 
         output = parser.gettext()
         self.assertEqual(output, expectedoutput)
 
+    def testbadlyformed(self):
+        try:
+            from rss2maildir import HTML2Text
+        except:
+            sys.path.append(os.path.sep.join(self.inputpath.split(os.path.sep)[0:-1]))
+            try:
+                from rss2maildir import HTML2Text
+            except:
+                self.assert_(False)
+
+        input_path = os.path.sep.join(os.path.dirname(os.path.realpath(__file__)).split(os.path.sep)[0:-1])
+        input = open(os.path.join(input_path, "html", "unorderedlist-badlyformed.html")).read()
+        expectedoutput = open(os.path.join(input_path, "expected", "unorderedlist-badlyformed.txt")).read()
+        parser = HTML2Text()
+        parser.feed(input)
+        output = parser.gettext()
+        self.assertEqual(output, expectedoutput)
+
 if __name__ == "__main__":
     unittest.main()
 if __name__ == "__main__":
     unittest.main()