Mercurial > hg
annotate tests/test-ui-config.py @ 13335:36f5fc742a5a stable
Added tag 1.7.5 for changeset 2b2155623ee2
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 01 Feb 2011 17:30:09 -0600 |
parents | 4c50552fc9bc |
children | fa2b596db182 |
rev | line source |
---|---|
8656 | 1 from mercurial import ui, dispatch, error |
2502
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
2 |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
3 testui = ui.ui() |
8137 | 4 parsed = dispatch._parseconfig(testui, [ |
2502
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
5 'values.string=string value', |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
6 'values.bool1=true', |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
7 'values.bool2=false', |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
8 'lists.list1=foo', |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
9 'lists.list2=foo bar baz', |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
10 'lists.list3=alice, bob', |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
11 'lists.list4=foo bar baz alice, bob', |
10982
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
12 'lists.list5=abc d"ef"g "hij def"', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
13 'lists.list6="hello world", "how are you?"', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
14 'lists.list7=Do"Not"Separate', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
15 'lists.list8="Do"Separate', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
16 'lists.list9="Do\\"NotSeparate"', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
17 'lists.list10=string "with extraneous" quotation mark"', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
18 'lists.list11=x, y', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
19 'lists.list12="x", "y"', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
20 'lists.list13=""" key = "x", "y" """', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
21 'lists.list14=,,,, ', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
22 'lists.list15=" just with starting quotation', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
23 'lists.list16="longer quotation" with "no ending quotation', |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
24 'lists.list17=this is \\" "not a quotation mark"', |
11309
ef7636efeb01
ui: handle leading newlines/spaces/commas in configlist
Thomas Arendsen Hein <thomas@intevation.de>
parents:
10982
diff
changeset
|
25 'lists.list18=\n \n\nding\ndong', |
2502
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
26 ]) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
27 |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
28 print repr(testui.configitems('values')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
29 print repr(testui.configitems('lists')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
30 print "---" |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
31 print repr(testui.config('values', 'string')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
32 print repr(testui.config('values', 'bool1')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
33 print repr(testui.config('values', 'bool2')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
34 print repr(testui.config('values', 'unknown')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
35 print "---" |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
36 try: |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
37 print repr(testui.configbool('values', 'string')) |
8144
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
8137
diff
changeset
|
38 except error.ConfigError, inst: |
4729
9881abfc0e44
Catch illegal boolean values in hgrc nicely.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4549
diff
changeset
|
39 print inst |
2502
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
40 print repr(testui.configbool('values', 'bool1')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
41 print repr(testui.configbool('values', 'bool2')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
42 print repr(testui.configbool('values', 'bool2', True)) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
43 print repr(testui.configbool('values', 'unknown')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
44 print repr(testui.configbool('values', 'unknown', True)) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
45 print "---" |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
46 print repr(testui.configlist('lists', 'list1')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
47 print repr(testui.configlist('lists', 'list2')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
48 print repr(testui.configlist('lists', 'list3')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
49 print repr(testui.configlist('lists', 'list4')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
50 print repr(testui.configlist('lists', 'list4', ['foo'])) |
10982
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
51 print repr(testui.configlist('lists', 'list5')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
52 print repr(testui.configlist('lists', 'list6')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
53 print repr(testui.configlist('lists', 'list7')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
54 print repr(testui.configlist('lists', 'list8')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
55 print repr(testui.configlist('lists', 'list9')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
56 print repr(testui.configlist('lists', 'list10')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
57 print repr(testui.configlist('lists', 'list11')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
58 print repr(testui.configlist('lists', 'list12')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
59 print repr(testui.configlist('lists', 'list13')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
60 print repr(testui.configlist('lists', 'list14')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
61 print repr(testui.configlist('lists', 'list15')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
62 print repr(testui.configlist('lists', 'list16')) |
0a548640e012
ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents:
8656
diff
changeset
|
63 print repr(testui.configlist('lists', 'list17')) |
11309
ef7636efeb01
ui: handle leading newlines/spaces/commas in configlist
Thomas Arendsen Hein <thomas@intevation.de>
parents:
10982
diff
changeset
|
64 print repr(testui.configlist('lists', 'list18')) |
2502
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
65 print repr(testui.configlist('lists', 'unknown')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
66 print repr(testui.configlist('lists', 'unknown', '')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
67 print repr(testui.configlist('lists', 'unknown', 'foo')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
68 print repr(testui.configlist('lists', 'unknown', ['foo'])) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
69 print repr(testui.configlist('lists', 'unknown', 'foo bar')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
70 print repr(testui.configlist('lists', 'unknown', 'foo, bar')) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
71 print repr(testui.configlist('lists', 'unknown', ['foo bar'])) |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
72 print repr(testui.configlist('lists', 'unknown', ['foo', 'bar'])) |
4069
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
73 |
8144
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
8137
diff
changeset
|
74 print repr(testui.config('values', 'String')) |
4069
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
75 |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
76 def function(): |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
77 pass |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
78 |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
79 # values that aren't strings should work |
8144
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
8137
diff
changeset
|
80 testui.setconfig('hook', 'commit', function) |
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
8137
diff
changeset
|
81 print function == testui.config('hook', 'commit') |