/functional_tests/test_doctest_plugin.py

https://bitbucket.org/jpellerin/nose/ · Python · 44 lines · 35 code · 9 blank · 0 comment · 4 complexity · ae5759f895bb8103c57db168ca8ff881 MD5 · raw file

  1. import os
  2. import unittest
  3. from nose.plugins.doctests import Doctest
  4. from nose.plugins import PluginTester
  5. support = os.path.join(os.path.dirname(__file__), 'support')
  6. class TestDoctestPlugin(PluginTester, unittest.TestCase):
  7. activate = '--with-doctest'
  8. args = ['-v']
  9. plugins = [Doctest()]
  10. suitepath = os.path.join(support, 'dtt')
  11. def runTest(self):
  12. print str(self.output)
  13. assert 'Doctest: some_mod ... ok' in self.output
  14. assert 'Doctest: some_mod.foo ... ok' in self.output
  15. assert 'Ran 2 tests' in self.output
  16. assert str(self.output).strip().endswith('OK')
  17. class TestDoctestFiles(PluginTester, unittest.TestCase):
  18. activate = '--with-doctest'
  19. args = ['-v', '--doctest-extension=.txt']
  20. plugins = [Doctest()]
  21. suitepath = os.path.join(support, 'dtt', 'docs')
  22. def runTest(self):
  23. print str(self.output)
  24. expect = [
  25. 'Doctest: doc.txt ... ok',
  26. 'Doctest: errdoc.txt ... FAIL'
  27. ]
  28. for line in self.output:
  29. if not line.strip():
  30. continue
  31. if line.startswith('='):
  32. break
  33. self.assertEqual(line.strip(), expect.pop(0))
  34. if __name__ == '__main__':
  35. unittest.main()