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