X-Git-Url: https://git.sommitrealweird.co.uk/rss2maildir.git/blobdiff_plain/9a4c55083ef741cd562529f93b331f4c583e61b7..0aa27bf39e80cd41081f4d5a49015e1c17ae9f68:/tests/runtests.py diff --git a/tests/runtests.py b/tests/runtests.py new file mode 100755 index 0000000..3af3248 --- /dev/null +++ b/tests/runtests.py @@ -0,0 +1,34 @@ +#!/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)