--- /dev/null
+#!/usr/bin/python
+
+import unittest
+import os
+
+basedir = os.path.realpath(os.path.dirname(__file__))
+unittestsdir = os.path.join( \
+ basedir, \
+ "unittests")
+
+unittestmodules = []
+
+fullsuite = unittest.TestSuite()
+
+# walk our directory tree looking for any modules available
+for root, dir, files in os.walk(unittestsdir):
+ for file in files:
+ if file[-3:] == ".py" and file != "__init__.py":
+ moduleinfo = ".".join(root[len(basedir)+1:].split(os.sep))
+ unittestmodules.append(".".join((moduleinfo, file[0:-3])))
+
+# run through the found modules and look for test suites
+for unittestmodule in unittestmodules:
+ # try importing the test and getting the suite
+ try:
+ suite_func = getattr(__import__(unittestmodule, {}, {}, ['']), "suite")
+ # add the suite to the tests
+ fullsuite.addTest(suite_func())
+ except:
+ # there was not test suite in there to run, skip it
+ pass
+
+testrunner = unittest.TextTestRunner()
+testrunner.run(fullsuite)
--- /dev/null
+#!/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()
def setUp(self):
self.inputpath = os.path.sep.join(os.path.dirname(os.path.realpath(__file__)).split(os.path.sep)[0:-1])
- def testwellformedlist(self):
+ def testWellFormedList(self):
try:
from rss2maildir import HTML2Text
except:
output = parser.gettext()
self.assertEqual(output, expectedoutput)
- def testbadlyformed(self):
+ def testBadlyFormedList(self):
try:
from rss2maildir import HTML2Text
except:
output = parser.gettext()
self.assertEqual(output, expectedoutput)
+def suite():
+ suite = unittest.TestSuite()
+ suite.addTest(UnorderedListTests("testWellFormedList"))
+ suite.addTest(UnorderedListTests("testBadlyFormedList"))
+ return suite
+
if __name__ == "__main__":
unittest.main()