File: test_doctest_plugin.py

package info (click to toggle)
nose 1.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,596 kB
  • ctags: 2,918
  • sloc: python: 15,595; makefile: 119; xml: 42; sh: 15
file content (44 lines) | stat: -rw-r--r-- 1,280 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import unittest
from nose.plugins.doctests import Doctest
from nose.plugins import PluginTester

support = os.path.join(os.path.dirname(__file__), 'support')

class TestDoctestPlugin(PluginTester, unittest.TestCase):
    activate = '--with-doctest'
    args = ['-v']
    plugins = [Doctest()]
    suitepath = os.path.join(support, 'dtt')
    
    def runTest(self):
        print str(self.output)
        
        assert 'Doctest: some_mod ... ok' in self.output
        assert 'Doctest: some_mod.foo ... ok' in self.output
        assert 'Ran 2 tests' in self.output
        assert str(self.output).strip().endswith('OK')


class TestDoctestFiles(PluginTester, unittest.TestCase):
    activate = '--with-doctest'
    args = ['-v', '--doctest-extension=.txt']
    plugins = [Doctest()]
    suitepath = os.path.join(support, 'dtt', 'docs')
    
    def runTest(self):
        print str(self.output)

        expect = [
            'Doctest: doc.txt ... ok',
            'Doctest: errdoc.txt ... FAIL'
            ]
        for line in self.output:
            if not line.strip():
                continue
            if line.startswith('='):
                break
            self.assertEqual(line.strip(), expect.pop(0))

if __name__ == '__main__':
    unittest.main()