Mercurial > hg
annotate tests/test-ui-config @ 7493:518afef5e350
Fix Bugzilla integration to work with new Bugzilla 3.2.
Bugzilla 3.2 changes the type of all MySQL tables it uses from MyISAM
to InnoDB. MyISAM does not support transactions, and performs an implied
commit after each update. InnoDB does support transactions, and so
exposes a bug where changes to the Bugzilla database were not committed,
and so with 3.2 are lost when the database connection closes.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Tue, 09 Dec 2008 09:58:13 +0000 |
parents | 18a9fbb5cd78 |
children | 7fd0616b3d80 |
rev | line source |
---|---|
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
|
1 #!/usr/bin/env python |
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 |
4069
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
3 import ConfigParser |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
4729
diff
changeset
|
4 from mercurial import ui, util, dispatch |
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 |
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 testui = ui.ui() |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
4729
diff
changeset
|
7 parsed = dispatch._parseconfig([ |
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
|
8 '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
|
9 '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
|
10 '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
|
11 '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
|
12 '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
|
13 '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
|
14 'lists.list4=foo bar baz alice, bob', |
3073
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
15 'interpolation.value1=hallo', |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
16 'interpolation.value2=%(value1)s world', |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
17 'interpolation.value3=%(novalue)s', |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
18 'interpolation.value4=%(bad)1', |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
19 'interpolation.value5=%bad2', |
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
|
20 ]) |
3346
1700a103458e
move the parsing of --config options to commands.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3073
diff
changeset
|
21 testui.updateopts(config=parsed) |
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
|
22 |
18cf95ad3666
Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
23 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
|
24 print repr(testui.configitems('lists')) |
3073
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
25 try: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
26 print repr(testui.configitems('interpolation')) |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
27 except util.Abort, inst: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
28 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
|
29 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
|
30 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
|
31 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
|
32 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
|
33 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
|
34 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
|
35 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
|
36 print repr(testui.configbool('values', 'string')) |
4729
9881abfc0e44
Catch illegal boolean values in hgrc nicely.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4549
diff
changeset
|
37 except util.Abort, inst: |
9881abfc0e44
Catch illegal boolean values in hgrc nicely.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4549
diff
changeset
|
38 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
|
39 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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 print repr(testui.configlist('lists', 'list4', ['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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 print "---" |
3073
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
59 print repr(testui.config('interpolation', 'value1')) |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
60 print repr(testui.config('interpolation', 'value2')) |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
61 try: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
62 print repr(testui.config('interpolation', 'value3')) |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
63 except util.Abort, inst: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
64 print inst |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
65 try: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
66 print repr(testui.config('interpolation', 'value4')) |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
67 except util.Abort, inst: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
68 print inst |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
69 try: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
70 print repr(testui.config('interpolation', 'value5')) |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
71 except util.Abort, inst: |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
72 print inst |
24c1db20990c
Include section name and parameter name (if available) in config errors.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2502
diff
changeset
|
73 print "---" |
4069
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
74 |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
75 cp = util.configparser() |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
76 cp.add_section('foo') |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
77 cp.set('foo', 'bar', 'baz') |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
78 try: |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
79 # should fail - keys are case-sensitive |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
80 cp.get('foo', 'Bar') |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
81 except ConfigParser.NoOptionError, inst: |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
82 print inst |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
83 |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
84 def function(): |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
85 pass |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
86 |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
87 cp.add_section('hook') |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
88 # values that aren't strings should work |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
89 cp.set('hook', 'commit', function) |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
90 f = cp.get('hook', 'commit') |
3fef134832d8
allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3346
diff
changeset
|
91 print "f %s= function" % (f == function and '=' or '!') |