test_pygrass_messages_doctests.py 1.2 KB

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