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