test_doctests.py 1.3 KB

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