X-Git-Url: https://git.sommitrealweird.co.uk/rss2maildir.git/blobdiff_plain/9a4c55083ef741cd562529f93b331f4c583e61b7..0aa27bf39e80cd41081f4d5a49015e1c17ae9f68:/tests/unittests/ParagraphTests.py diff --git a/tests/unittests/ParagraphTests.py b/tests/unittests/ParagraphTests.py new file mode 100755 index 0000000..9111ecd --- /dev/null +++ b/tests/unittests/ParagraphTests.py @@ -0,0 +1,34 @@ +#!/usr/bin/python + +import unittest +import sys +import os + +class ParagraphTests(unittest.TestCase): + def setUp(self): + self.inputpath = os.path.sep.join(os.path.dirname(os.path.realpath(__file__)).split(os.path.sep)[0:-1]) + + def testWellFormedParagraphs(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", "multiparagraph-wellformed.html")).read() + expectedoutput = open(os.path.join(input_path, "expected", "multiparagraph-wellformed.txt")).read() + parser = HTML2Text() + parser.feed(input) + output = parser.gettext() + self.assertEqual(output, expectedoutput) + +def suite(): + suite = unittest.TestSuite() + suite.addTest(ParagraphTests("testWellFormedParagraphs")) + return suite + +if __name__ == "__main__": + unittest.main()