test_doctests.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # -*- coding: utf-8 -*-
  2. """
  3. Tests checkers
  4. """
  5. import doctest
  6. import grass.gunittest.case
  7. import grass.gunittest.main
  8. import grass.gunittest.utils
  9. import grass.pygrass.vector as gvector
  10. import grass.pygrass.utils as gutils
  11. # doctest does not allow changing the base classes of test case, skip test case
  12. # and test suite, so we need to create a new type which inherits from our class
  13. # and contains doctest's methods
  14. # the alternative is to copy 500 from doctest and change what is needed
  15. # (this might be necessary anyway beacuse of the reports and stdout and stderr)
  16. doctest.DocFileCase = type('DocFileCase',
  17. (grass.gunittest.case.TestCase,),
  18. dict(doctest.DocFileCase.__dict__))
  19. doctest.SkipDocTestCase = type('SkipDocTestCase',
  20. (grass.gunittest.case.TestCase,),
  21. dict(doctest.SkipDocTestCase.__dict__))
  22. def load_tests(loader, tests, ignore):
  23. # TODO: this must be somewhere when doctest is called, not here
  24. # TODO: ultimate solution is not to use _ as a buildin in lib/python
  25. # for now it is the only place where it works
  26. grass.gunittest.utils.do_doctest_gettext_workaround()
  27. from grass.pygrass import utils
  28. utils.create_test_vector_map(gvector.test_vector_name)
  29. utils.create_test_vector_map(gvector.abstract.test_vector_name)
  30. utils.create_test_vector_map(gvector.geometry.test_vector_name)
  31. utils.create_test_vector_map(gvector.find.test_vector_name)
  32. # this should be called at some top level
  33. tests.addTests(doctest.DocTestSuite(gvector))
  34. tests.addTests(doctest.DocTestSuite(gvector.abstract))
  35. tests.addTests(doctest.DocTestSuite(gvector.basic))
  36. tests.addTests(doctest.DocTestSuite(gvector.find))
  37. tests.addTests(doctest.DocTestSuite(gvector.geometry))
  38. tests.addTests(doctest.DocTestSuite(gvector.sql))
  39. #tests.addTests(doctest.DocTestSuite(gvector.table))
  40. return tests
  41. if __name__ == '__main__':
  42. grass.gunittest.main.test()