From 86c0830f4b4151fce5a94f831b885f2eff9fa2f2 Mon Sep 17 00:00:00 2001 From: John Ehresman Date: Sun, 4 Jul 2004 19:44:27 +0000 Subject: tests directory: unit tests --- tests/testsupport.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/testsupport.py (limited to 'tests/testsupport.py') diff --git a/tests/testsupport.py b/tests/testsupport.py new file mode 100644 index 0000000..bc23975 --- /dev/null +++ b/tests/testsupport.py @@ -0,0 +1,30 @@ +# -*- Mode: Python; py-indent-offset: 4 -*- + +import sys +import os +import unittest +import __main__ + +# Insert parent directory into path +def insert_pygtk_python_paths(): + try: + filename = __file__ + except: + filename = sys.argv[0] + this_dir = os.path.dirname(os.path.abspath(filename)) + parent_dir = os.path.dirname(this_dir) + sys.path.insert(0, parent_dir) + +insert_pygtk_python_paths() + +def run_all_tests(mods = [__main__]): + runner = unittest.TextTestRunner() + for mod in mods: + for name in dir(mod): + val = getattr(mod, name) + try: + if issubclass(val, unittest.TestCase): + suite = unittest.makeSuite(val, 'test') + runner.run(suite) + except TypeError: + pass -- cgit