##// END OF EJS Templates
tests: alias ui as uimod in test-ui-config
Yuya Nishihara -
r28776:5508a277 default
parent child Browse files
Show More
@@ -1,103 +1,103 b''
1 1 from __future__ import absolute_import, print_function
2 2 from mercurial import (
3 3 dispatch,
4 4 error,
5 ui,
5 ui as uimod,
6 6 )
7 7
8 testui = ui.ui()
8 testui = uimod.ui()
9 9 parsed = dispatch._parseconfig(testui, [
10 10 'values.string=string value',
11 11 'values.bool1=true',
12 12 'values.bool2=false',
13 13 'values.boolinvalid=foo',
14 14 'values.int1=42',
15 15 'values.int2=-42',
16 16 'values.intinvalid=foo',
17 17 'lists.list1=foo',
18 18 'lists.list2=foo bar baz',
19 19 'lists.list3=alice, bob',
20 20 'lists.list4=foo bar baz alice, bob',
21 21 'lists.list5=abc d"ef"g "hij def"',
22 22 'lists.list6="hello world", "how are you?"',
23 23 'lists.list7=Do"Not"Separate',
24 24 'lists.list8="Do"Separate',
25 25 'lists.list9="Do\\"NotSeparate"',
26 26 'lists.list10=string "with extraneous" quotation mark"',
27 27 'lists.list11=x, y',
28 28 'lists.list12="x", "y"',
29 29 'lists.list13=""" key = "x", "y" """',
30 30 'lists.list14=,,,, ',
31 31 'lists.list15=" just with starting quotation',
32 32 'lists.list16="longer quotation" with "no ending quotation',
33 33 'lists.list17=this is \\" "not a quotation mark"',
34 34 'lists.list18=\n \n\nding\ndong',
35 35 ])
36 36
37 37 print(repr(testui.configitems('values')))
38 38 print(repr(testui.configitems('lists')))
39 39 print("---")
40 40 print(repr(testui.config('values', 'string')))
41 41 print(repr(testui.config('values', 'bool1')))
42 42 print(repr(testui.config('values', 'bool2')))
43 43 print(repr(testui.config('values', 'unknown')))
44 44 print("---")
45 45 try:
46 46 print(repr(testui.configbool('values', 'string')))
47 47 except error.ConfigError as inst:
48 48 print(inst)
49 49 print(repr(testui.configbool('values', 'bool1')))
50 50 print(repr(testui.configbool('values', 'bool2')))
51 51 print(repr(testui.configbool('values', 'bool2', True)))
52 52 print(repr(testui.configbool('values', 'unknown')))
53 53 print(repr(testui.configbool('values', 'unknown', True)))
54 54 print("---")
55 55 print(repr(testui.configint('values', 'int1')))
56 56 print(repr(testui.configint('values', 'int2')))
57 57 print("---")
58 58 print(repr(testui.configlist('lists', 'list1')))
59 59 print(repr(testui.configlist('lists', 'list2')))
60 60 print(repr(testui.configlist('lists', 'list3')))
61 61 print(repr(testui.configlist('lists', 'list4')))
62 62 print(repr(testui.configlist('lists', 'list4', ['foo'])))
63 63 print(repr(testui.configlist('lists', 'list5')))
64 64 print(repr(testui.configlist('lists', 'list6')))
65 65 print(repr(testui.configlist('lists', 'list7')))
66 66 print(repr(testui.configlist('lists', 'list8')))
67 67 print(repr(testui.configlist('lists', 'list9')))
68 68 print(repr(testui.configlist('lists', 'list10')))
69 69 print(repr(testui.configlist('lists', 'list11')))
70 70 print(repr(testui.configlist('lists', 'list12')))
71 71 print(repr(testui.configlist('lists', 'list13')))
72 72 print(repr(testui.configlist('lists', 'list14')))
73 73 print(repr(testui.configlist('lists', 'list15')))
74 74 print(repr(testui.configlist('lists', 'list16')))
75 75 print(repr(testui.configlist('lists', 'list17')))
76 76 print(repr(testui.configlist('lists', 'list18')))
77 77 print(repr(testui.configlist('lists', 'unknown')))
78 78 print(repr(testui.configlist('lists', 'unknown', '')))
79 79 print(repr(testui.configlist('lists', 'unknown', 'foo')))
80 80 print(repr(testui.configlist('lists', 'unknown', ['foo'])))
81 81 print(repr(testui.configlist('lists', 'unknown', 'foo bar')))
82 82 print(repr(testui.configlist('lists', 'unknown', 'foo, bar')))
83 83 print(repr(testui.configlist('lists', 'unknown', ['foo bar'])))
84 84 print(repr(testui.configlist('lists', 'unknown', ['foo', 'bar'])))
85 85
86 86 print(repr(testui.config('values', 'String')))
87 87
88 88 def function():
89 89 pass
90 90
91 91 # values that aren't strings should work
92 92 testui.setconfig('hook', 'commit', function)
93 93 print(function == testui.config('hook', 'commit'))
94 94
95 95 # invalid values
96 96 try:
97 97 testui.configbool('values', 'boolinvalid')
98 98 except error.ConfigError:
99 99 print('boolinvalid')
100 100 try:
101 101 testui.configint('values', 'intinvalid')
102 102 except error.ConfigError:
103 103 print('intinvalid')
General Comments 0
You need to be logged in to leave comments. Login now