annotate tests/test-ui-config.py @ 35507:95a9be56c3bb

largefiles: modernize how capabilities are added to the wire protocol See 982f13bef503, which came well after this code was originally written.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 26 Dec 2017 23:40:49 -0500
parents 85a2db47ad50
children 3740d1abde44
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()
34858
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
9
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
10 # disable the configuration registration warning
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
11 #
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
12 # the purpose of this test is to check the old behavior, not to validate the
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
13 # behavior from registered item. so we silent warning related to unregisted
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
14 # config.
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
15 testui.setconfig('devel', 'warn-config-unknown', False, 'test')
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
16 testui.setconfig('devel', 'all-warnings', False, 'test')
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
17
8137
7fd0616b3d80 ui: kill updateopts
Matt Mackall <mpm@selenic.com>
parents: 5178
diff changeset
18 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
19 '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
20 '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
21 'values.bool2=false',
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
22 'values.boolinvalid=foo',
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
23 'values.int1=42',
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
24 'values.int2=-42',
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
25 '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
26 '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
27 '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
28 '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
29 'lists.list4=foo bar baz alice, bob',
10982
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
30 'lists.list5=abc d"ef"g "hij def"',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
31 'lists.list6="hello world", "how are you?"',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
32 'lists.list7=Do"Not"Separate',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
33 'lists.list8="Do"Separate',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
34 'lists.list9="Do\\"NotSeparate"',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
35 'lists.list10=string "with extraneous" quotation mark"',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
36 'lists.list11=x, y',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
37 'lists.list12="x", "y"',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
38 'lists.list13=""" key = "x", "y" """',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
39 'lists.list14=,,,, ',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
40 'lists.list15=" just with starting quotation',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
41 'lists.list16="longer quotation" with "no ending quotation',
0a548640e012 ui: support quotes in configlist (issue2147)
Henrik Stuart <hg@hstuart.dk>
parents: 8656
diff changeset
42 '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
43 '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
44 'date.epoch=0 0',
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
45 '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
46 'date.invalid=0'
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
47 ])
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
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
49 print(repr(testui.configitems('values')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
50 print(repr(testui.configitems('lists')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
51 print("---")
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
52 print(repr(testui.config('values', 'string')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
53 print(repr(testui.config('values', 'bool1')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
54 print(repr(testui.config('values', 'bool2')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
55 print(repr(testui.config('values', 'unknown')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
56 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
57 try:
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
58 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
59 except error.ConfigError as inst:
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
60 print(inst)
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
61 print(repr(testui.configbool('values', 'bool1')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
62 print(repr(testui.configbool('values', 'bool2')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
63 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
64 print(repr(testui.configbool('values', 'unknown')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
65 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
66 print("---")
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
67 print(repr(testui.configint('values', 'int1')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
68 print(repr(testui.configint('values', 'int2')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
69 print("---")
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
70 print(repr(testui.configlist('lists', 'list1')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
71 print(repr(testui.configlist('lists', 'list2')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
72 print(repr(testui.configlist('lists', 'list3')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
73 print(repr(testui.configlist('lists', 'list4')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
74 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
75 print(repr(testui.configlist('lists', 'list5')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
76 print(repr(testui.configlist('lists', 'list6')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
77 print(repr(testui.configlist('lists', 'list7')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
78 print(repr(testui.configlist('lists', 'list8')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
79 print(repr(testui.configlist('lists', 'list9')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
80 print(repr(testui.configlist('lists', 'list10')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
81 print(repr(testui.configlist('lists', 'list11')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
82 print(repr(testui.configlist('lists', 'list12')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
83 print(repr(testui.configlist('lists', 'list13')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
84 print(repr(testui.configlist('lists', 'list14')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
85 print(repr(testui.configlist('lists', 'list15')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
86 print(repr(testui.configlist('lists', 'list16')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
87 print(repr(testui.configlist('lists', 'list17')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
88 print(repr(testui.configlist('lists', 'list18')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
89 print(repr(testui.configlist('lists', 'unknown')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
90 print(repr(testui.configlist('lists', 'unknown', '')))
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
91 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
92 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
93 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
94 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
95 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
96 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
97 print("---")
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
98 print(repr(testui.configdate('date', 'epoch')))
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
99 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
100
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
101 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
102
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
103 def function():
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
104 pass
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
105
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
106 # values that aren't strings should work
8144
fca54469480e ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents: 8137
diff changeset
107 testui.setconfig('hook', 'commit', function)
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
108 print(function == testui.config('hook', 'commit'))
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
109
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
110 # invalid values
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
111 try:
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
112 testui.configbool('values', 'boolinvalid')
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
113 except error.ConfigError:
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
114 print('boolinvalid')
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
115 try:
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
116 testui.configint('values', 'intinvalid')
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
117 except error.ConfigError:
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
118 print('intinvalid')
32449
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
119 try:
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
120 testui.configdate('date', 'invalid')
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
121 except error.ConfigError:
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
122 print('dateinvalid')