瀏覽代碼

Add test to read the xml interface of all the GRASS modules

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@60942 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 11 年之前
父節點
當前提交
e177aba9f1
共有 1 個文件被更改,包括 36 次插入0 次删除
  1. 36 0
      lib/python/pygrass/modules/interface/testsuite/test_modules.py

+ 36 - 0
lib/python/pygrass/modules/interface/testsuite/test_modules.py

@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Tue Jun 24 09:43:53 2014
+
+@author: pietro
+"""
+import unittest
+
+from grass.script.core import get_commands
+from grass.pygrass.modules.interface import Module
+
+
+SKIP = []
+
+
+class TestModulesMeta(type):
+    def __new__(mcs, name, bases, dict):
+
+        def gen_test(cmd):
+            def test(self):
+                Module(cmd)
+            return test
+
+        cmds = [c for c in sorted(list(get_commands()[0])) if c not in SKIP]
+        for cmd in cmds:
+            test_name = "test__%s" % cmd.replace('.', '_')
+            dict[test_name] = gen_test(cmd)
+        return type.__new__(mcs, name, bases, dict)
+
+
+class TestModules(unittest.TestCase):
+    __metaclass__ = TestModulesMeta
+
+
+if __name__ == '__main__':
+    unittest.main()