test_modules.py 771 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Jun 24 09:43:53 2014
  4. @author: pietro
  5. """
  6. import unittest
  7. from grass.script.core import get_commands
  8. from grass.pygrass.modules.interface import Module
  9. SKIP = []
  10. class TestModulesMeta(type):
  11. def __new__(mcs, name, bases, dict):
  12. def gen_test(cmd):
  13. def test(self):
  14. Module(cmd)
  15. return test
  16. cmds = [c for c in sorted(list(get_commands()[0])) if c not in SKIP]
  17. for cmd in cmds:
  18. test_name = "test__%s" % cmd.replace('.', '_')
  19. dict[test_name] = gen_test(cmd)
  20. return type.__new__(mcs, name, bases, dict)
  21. class TestModules(unittest.TestCase):
  22. __metaclass__ = TestModulesMeta
  23. if __name__ == '__main__':
  24. unittest.main()