From 07427cd408cc9321b1cd0e6a63802d6dfd12547e Mon Sep 17 00:00:00 2001 From: Per Cederqvist <ceder@lysator.liu.se> Date: Wed, 19 Jan 2005 14:28:04 +0000 Subject: [PATCH] New file. Run all automatic tests. --- testdriver.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 testdriver.py diff --git a/testdriver.py b/testdriver.py new file mode 100755 index 0000000..1138882 --- /dev/null +++ b/testdriver.py @@ -0,0 +1,35 @@ +#! /usr/bin/env python + +import os +import sys + +import unittest + +def findsuites(): + suites = [] + for fn in os.listdir('test'): + if fn.startswith('test_') and fn.endswith('.py'): + suites.append('test.' + fn[:-3]) + suites.sort() + return suites + +def my_import(name): + mod = __import__(name) + components = name.split('.') + for comp in components[1:]: + mod = getattr(mod, comp) + return mod + +def main(): + suites = findsuites() + all = unittest.TestSuite() + load = unittest.defaultTestLoader.loadTestsFromModule + for suite in suites: + all.addTest(load(my_import(suite))) + res = unittest.TextTestRunner().run(all) + res.stream = unittest._WritelnDecorator(open("test.result", "w")) + res.printErrors() + return not res.wasSuccessful() + +if __name__ == '__main__': + main() -- GitLab