##// END OF EJS Templates
tests: fix test-run-tests.py on OS X...
Simon Heimberg -
r20284:e1e6ddae default
parent child Browse files
Show More
@@ -1,84 +1,87 b''
1 1 """test line matching with some failing examples and some which warn
2 2
3 3 run-test.t only checks positive matches and can not see warnings
4 4 (both by design)
5 5 """
6 6
7
8 import doctest, os, re
7 import os, re
8 # this is hack to make sure no escape characters are inserted into the output
9 if 'TERM' in os.environ:
10 del os.environ['TERM']
11 import doctest
9 12 run_tests = __import__('run-tests')
10 13
11 14 def lm(expected, output):
12 15 r"""check if output matches expected
13 16
14 17 does it generally work?
15 18 >>> lm('H*e (glob)\n', 'Here\n')
16 19 True
17 20
18 21 fail on bad test data
19 22 >>> try: lm('a\n','a')
20 23 ... except AssertionError, ex: print ex
21 24 missing newline
22 25 >>> try: lm('single backslash\n', 'single \backslash\n')
23 26 ... except AssertionError, ex: print ex
24 27 single backslash or unknown char
25 28 """
26 29 assert expected.endswith('\n') and output.endswith('\n'), 'missing newline'
27 30 assert not re.search(r'[^ \w\\/\r\n()*?]', expected + output), \
28 31 'single backslash or unknown char'
29 32 match = run_tests.linematch(expected, output)
30 33 if isinstance(match, str):
31 34 return 'special: ' + match
32 35 else:
33 36 return bool(match) # do not return match object
34 37
35 38 def wintests():
36 39 r"""test matching like running on windows
37 40
38 41 enable windows matching on any os
39 42 >>> _osaltsep = os.altsep
40 43 >>> os.altsep = True
41 44
42 45 valid match on windows
43 46 >>> lm('g/a*/d (glob)\n', 'g\\abc/d\n')
44 47 True
45 48
46 49 direct matching, glob unnecessary
47 50 >>> lm('g/b (glob)\n', 'g/b\n')
48 51 'special: -glob'
49 52
50 53 missing glob
51 54 >>> lm('/g/c/d/fg\n', '\\g\\c\\d/fg\n')
52 55 'special: +glob'
53 56
54 57 restore os.altsep
55 58 >>> os.altsep = _osaltsep
56 59 """
57 os.altsep # for pyflakes, because it does not see os in the doctest
60 pass
58 61
59 62 def otherostests():
60 63 r"""test matching like running on non-windows os
61 64
62 65 disable windows matching on any os
63 66 >>> _osaltsep = os.altsep
64 67 >>> os.altsep = False
65 68
66 69 backslash does not match slash
67 70 >>> lm('h/a* (glob)\n', 'h\\ab\n')
68 71 False
69 72
70 73 direct matching glob can not be recognized
71 74 >>> lm('h/b (glob)\n', 'h/b\n')
72 75 True
73 76
74 77 missing glob can not not be recognized
75 78 >>> lm('/h/c/df/g/\n', '\\h/c\\df/g\\\n')
76 79 False
77 80
78 81 restore os.altsep
79 82 >>> os.altsep = _osaltsep
80 83 """
81 84 pass
82 85
83 86 if __name__ == '__main__':
84 87 doctest.testmod()
General Comments 0
You need to be logged in to leave comments. Login now