Commits

Ralf Schmitt committed d87b787

dynamically generate test functions in test__execmodules.py

Comments (0)

Files changed (1)

greentest/test__execmodules.py

 import sys
-import traceback
-from greentest import walk_modules
+from greentest import walk_modules, BaseTestCase, main
+
+
+class TestExec(BaseTestCase):
+    pass
+
+
+def make_exec_test(path, module):
+
+    def test(self):
+        sys.stderr.write('%s %s\n' % (module, path))
+        execfile(path, {})
+
+    name = "test_" + module.replace(".", "_")
+    test.__name__ = name
+    setattr(TestExec, name, test)
 
 
 for path, module in walk_modules():
-    sys.stderr.write('%s %s\n' % (module, path))
-    try:
-        execfile(path)
-    except Exception:
-        traceback.print_exc()
+    make_exec_test(path, module)
+
+if __name__ == '__main__':
+    main()