##// END OF EJS Templates
test-doctest: include dateutil...
Jun Wu -
r44169:92518ca6 default draft
parent child Browse files
Show More
@@ -1,94 +1,95 b''
1 1 # this is hack to make sure no escape characters are inserted into the output
2 2
3 3 from __future__ import absolute_import
4 4
5 5 import doctest
6 6 import os
7 7 import re
8 8 import sys
9 9
10 10 ispy3 = sys.version_info[0] >= 3
11 11
12 12 if 'TERM' in os.environ:
13 13 del os.environ['TERM']
14 14
15 15
16 16 class py3docchecker(doctest.OutputChecker):
17 17 def check_output(self, want, got, optionflags):
18 18 want2 = re.sub(r'''\bu(['"])(.*?)\1''', r'\1\2\1', want) # py2: u''
19 19 got2 = re.sub(r'''\bb(['"])(.*?)\1''', r'\1\2\1', got) # py3: b''
20 20 # py3: <exc.name>: b'<msg>' -> <name>: <msg>
21 21 # <exc.name>: <others> -> <name>: <others>
22 22 got2 = re.sub(
23 23 r'''^mercurial\.\w+\.(\w+): (['"])(.*?)\2''',
24 24 r'\1: \3',
25 25 got2,
26 26 re.MULTILINE,
27 27 )
28 28 got2 = re.sub(r'^mercurial\.\w+\.(\w+): ', r'\1: ', got2, re.MULTILINE)
29 29 return any(
30 30 doctest.OutputChecker.check_output(self, w, g, optionflags)
31 31 for w, g in [(want, got), (want2, got2)]
32 32 )
33 33
34 34
35 35 def testmod(name, optionflags=0, testtarget=None):
36 36 __import__(name)
37 37 mod = sys.modules[name]
38 38 if testtarget is not None:
39 39 mod = getattr(mod, testtarget)
40 40
41 41 # minimal copy of doctest.testmod()
42 42 finder = doctest.DocTestFinder()
43 43 checker = None
44 44 if ispy3:
45 45 checker = py3docchecker()
46 46 runner = doctest.DocTestRunner(checker=checker, optionflags=optionflags)
47 47 for test in finder.find(mod, name):
48 48 runner.run(test)
49 49 runner.summarize()
50 50
51 51
52 52 testmod('mercurial.changegroup')
53 53 testmod('mercurial.changelog')
54 54 testmod('mercurial.cmdutil')
55 55 testmod('mercurial.color')
56 56 testmod('mercurial.config')
57 57 testmod('mercurial.context')
58 58 testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
59 59 testmod('mercurial.dispatch')
60 60 testmod('mercurial.encoding')
61 61 testmod('mercurial.fancyopts')
62 62 testmod('mercurial.formatter')
63 63 testmod('mercurial.hg')
64 64 testmod('mercurial.hgweb.hgwebdir_mod')
65 65 testmod('mercurial.match')
66 66 testmod('mercurial.mdiff')
67 67 testmod('mercurial.minirst')
68 68 testmod('mercurial.patch')
69 69 testmod('mercurial.pathutil')
70 70 testmod('mercurial.parser')
71 71 testmod('mercurial.pycompat')
72 72 testmod('mercurial.revlog')
73 73 testmod('mercurial.revlogutils.deltas')
74 74 testmod('mercurial.revset')
75 75 testmod('mercurial.revsetlang')
76 76 testmod('mercurial.smartset')
77 77 testmod('mercurial.store')
78 78 testmod('mercurial.subrepo')
79 79 testmod('mercurial.templatefilters')
80 80 testmod('mercurial.templater')
81 81 testmod('mercurial.ui')
82 82 testmod('mercurial.url')
83 83 testmod('mercurial.util')
84 84 testmod('mercurial.util', testtarget='platform')
85 testmod('mercurial.utils.dateutil')
85 86 testmod('mercurial.utils.stringutil')
86 87 testmod('hgext.convert.convcmd')
87 88 testmod('hgext.convert.cvsps')
88 89 testmod('hgext.convert.filemap')
89 90 testmod('hgext.convert.p4')
90 91 testmod('hgext.convert.subversion')
91 92 testmod('hgext.fix')
92 93 testmod('hgext.mq')
93 94 # Helper scripts in tests/ that have doctests:
94 95 testmod('drawdag')
General Comments 0
You need to be logged in to leave comments. Login now