905897307c31b3a198f5b164ea40befcf1836f51
[rss2maildir.git] / tests / unittests / DefinitionListTests.py
1 #!/usr/bin/python
2
3 import unittest
4 import sys
5 import os
6
7 class DefinitionListTests(unittest.TestCase):
8     def setUp(self):
9         self.inputpath = os.path.sep.join(os.path.dirname(os.path.realpath(__file__)).split(os.path.sep)[0:-1])
10
11     def testWellFormedDefinitionList(self):
12         try:
13             from rss2maildir import HTML2Text
14         except:
15             sys.path.append(os.path.sep.join(self.inputpath.split(os.path.sep)[0:-1]))
16             try:
17                 from rss2maildir import HTML2Text
18             except:
19                 self.assert_(False)
20         input_path = os.path.sep.join(os.path.dirname(os.path.realpath(__file__)).split(os.path.sep)[0:-1])
21         input = open(os.path.join(input_path, "html", "definitionlist-wellformed.html")).read()
22         expectedoutput = open(os.path.join(input_path, "expected", "definitionlist-wellformed.txt")).read()
23         parser = HTML2Text()
24         parser.feed(input)
25         output = parser.gettext()
26         self.assertEqual(output, expectedoutput)
27
28 def suite():
29     suite = unittest.TestSuite()
30     suite.addTest(DefinitionListTests("testWellFormedDefinitionList"))
31     return suite
32
33 if __name__ == "__main__":
34     unittest.main()