annotate tests/test-ui-config.py @ 33488:eb344bbac18c

bookmark: use 'applychanges' when stripping
author Boris Feld <boris.feld@octobus.net>
date Mon, 10 Jul 2017 17:37:48 +0200
parents 0ed730f3301c
children 85a2db47ad50
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
1 from __future__ import absolute_import, print_function
28680
ae606bdedc3e py3: make test-ui-config use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25660
diff changeset
2 from mercurial import (
ae606bdedc3e py3: make test-ui-config use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25660
diff changeset
3 dispatch,
ae606bdedc3e py3: make test-ui-config use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25660
diff changeset
4 error,
28776
5508a277bab2 tests: alias ui as uimod in test-ui-config
Yuya Nishihara <yuya@tcha.org>
parents: 28681
diff changeset
5 ui as uimod,
28680
ae606bdedc3e py3: make test-ui-config use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25660
diff changeset
6 )
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
7
30559
d83ca854fa21 ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28776
diff changeset
8 testui = uimod.ui.load()
8137
7fd0616b3d80 ui: kill updateopts
Matt Mackall <mpm@selenic.com>
parents: 5178
diff changeset
9 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
10 '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
11 '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
12 'values.bool2=false',
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
13 'values.boolinvalid=foo',
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
14 'values.int1=42',
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
15 'values.int2=-42',
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
16 'values.intinvalid=foo',
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
17 '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
18 '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
19 '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
20 'lists.list4=foo bar baz alice, bob',
10982
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
21 'lists.list5=abc d"ef"g "hij def"',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
22 'lists.list6="hello world", "how are you?"',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
23 'lists.list7=Do"Not"Separate',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
24 'lists.list8="Do"Separate',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
25 'lists.list9="Do\\"NotSeparate"',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
26 'lists.list10=string "with extraneous" quotation mark"',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
27 'lists.list11=x, y',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
28 'lists.list12="x", "y"',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
29 'lists.list13=""" key = "x", "y" """',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
30 'lists.list14=,,,, ',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
31 'lists.list15=" just with starting quotation',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
32 'lists.list16="longer quotation" with "no ending quotation',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
33 '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
34 'lists.list18=\n \n\nding\ndong',
32449
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
35 'date.epoch=0 0',
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
36 'date.birth=2005-04-19T00:00:00',
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
37 'date.invalid=0'
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
38 ])
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
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
40 print(repr(testui.configitems('values')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
41 print(repr(testui.configitems('lists')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
42 print("---")
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
43 print(repr(testui.config('values', 'string')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
44 print(repr(testui.config('values', 'bool1')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
45 print(repr(testui.config('values', 'bool2')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
46 print(repr(testui.config('values', 'unknown')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
47 print("---")
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
48 try:
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
49 print(repr(testui.configbool('values', 'string')))
25660
328739ea70c3 global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents: 14171
diff changeset
50 except error.ConfigError as inst:
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
51 print(inst)
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
52 print(repr(testui.configbool('values', 'bool1')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
53 print(repr(testui.configbool('values', 'bool2')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
54 print(repr(testui.configbool('values', 'bool2', True)))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
55 print(repr(testui.configbool('values', 'unknown')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
56 print(repr(testui.configbool('values', 'unknown', True)))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
57 print("---")
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
58 print(repr(testui.configint('values', 'int1')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
59 print(repr(testui.configint('values', 'int2')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
60 print("---")
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
61 print(repr(testui.configlist('lists', 'list1')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
62 print(repr(testui.configlist('lists', 'list2')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
63 print(repr(testui.configlist('lists', 'list3')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
64 print(repr(testui.configlist('lists', 'list4')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
65 print(repr(testui.configlist('lists', 'list4', ['foo'])))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
66 print(repr(testui.configlist('lists', 'list5')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
67 print(repr(testui.configlist('lists', 'list6')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
68 print(repr(testui.configlist('lists', 'list7')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
69 print(repr(testui.configlist('lists', 'list8')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
70 print(repr(testui.configlist('lists', 'list9')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
71 print(repr(testui.configlist('lists', 'list10')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
72 print(repr(testui.configlist('lists', 'list11')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
73 print(repr(testui.configlist('lists', 'list12')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
74 print(repr(testui.configlist('lists', 'list13')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
75 print(repr(testui.configlist('lists', 'list14')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
76 print(repr(testui.configlist('lists', 'list15')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
77 print(repr(testui.configlist('lists', 'list16')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
78 print(repr(testui.configlist('lists', 'list17')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
79 print(repr(testui.configlist('lists', 'list18')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
80 print(repr(testui.configlist('lists', 'unknown')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
81 print(repr(testui.configlist('lists', 'unknown', '')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
82 print(repr(testui.configlist('lists', 'unknown', 'foo')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
83 print(repr(testui.configlist('lists', 'unknown', ['foo'])))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
84 print(repr(testui.configlist('lists', 'unknown', 'foo bar')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
85 print(repr(testui.configlist('lists', 'unknown', 'foo, bar')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
86 print(repr(testui.configlist('lists', 'unknown', ['foo bar'])))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
87 print(repr(testui.configlist('lists', 'unknown', ['foo', 'bar'])))
32449
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
88 print("---")
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
89 print(repr(testui.configdate('date', 'epoch')))
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
90 print(repr(testui.configdate('date', 'birth')))
4069
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
91
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
92 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
93
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
94 def function():
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
95 pass
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
96
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
97 # values that aren't strings should work
8144
fca54469480e ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents: 8137
diff changeset
98 testui.setconfig('hook', 'commit', function)
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
99 print(function == testui.config('hook', 'commit'))
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
100
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
101 # invalid values
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
102 try:
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
103 testui.configbool('values', 'boolinvalid')
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
104 except error.ConfigError:
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
105 print('boolinvalid')
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
106 try:
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
107 testui.configint('values', 'intinvalid')
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
108 except error.ConfigError:
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
109 print('intinvalid')
32449
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
110 try:
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
111 testui.configdate('date', 'invalid')
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
112 except error.ConfigError:
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
113 print('dateinvalid')