From: Brett Parker Date: Mon, 31 Dec 2007 02:56:28 +0000 (+0000) Subject: * Add unit test for some of the badly formed lists that we get after the X-Git-Url: https://git.sommitrealweird.co.uk/rss2maildir.git/commitdiff_plain/826d674cb3aea5d61f50bfc7410aeee23def33bd * Add unit test for some of the badly formed lists that we get after the feedparser "sanitizer" has a word with the HTML (currently fails) --- diff --git a/tests/expected/unorderedlist-badlyformed.txt b/tests/expected/unorderedlist-badlyformed.txt new file mode 100644 index 0000000..49d47f6 --- /dev/null +++ b/tests/expected/unorderedlist-badlyformed.txt @@ -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 index 0000000..b37ec7f --- /dev/null +++ b/tests/html/unorderedlist-badlyformed.html @@ -0,0 +1,6 @@ + diff --git a/tests/unittests/UnorderedListTests.py b/tests/unittests/UnorderedListTests.py old mode 100644 new mode 100755 index af09b7c..4d2c393 --- a/tests/unittests/UnorderedListTests.py +++ b/tests/unittests/UnorderedListTests.py @@ -25,5 +25,23 @@ class UnorderedListTests(unittest.TestCase): 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()