##// END OF EJS Templates
Merge with crew-stable
Merge with crew-stable

File last commit:

r8144:fca54469 default
r8166:56719b1a merge default
Show More
test-ui-config
55 lines | 1.9 KiB | text/plain | TextLexer
Thomas Arendsen Hein
Allow using default values with ui.configlist, too, and add a test for this.
r2502 #!/usr/bin/env python
Matt Mackall
ui: introduce new config parser
r8144 from mercurial import ui, util, dispatch, error
Thomas Arendsen Hein
Allow using default values with ui.configlist, too, and add a test for this.
r2502
testui = ui.ui()
Matt Mackall
ui: kill updateopts...
r8137 parsed = dispatch._parseconfig(testui, [
Thomas Arendsen Hein
Allow using default values with ui.configlist, too, and add a test for this.
r2502 'values.string=string value',
'values.bool1=true',
'values.bool2=false',
'lists.list1=foo',
'lists.list2=foo bar baz',
'lists.list3=alice, bob',
'lists.list4=foo bar baz alice, bob',
])
print repr(testui.configitems('values'))
print repr(testui.configitems('lists'))
print "---"
print repr(testui.config('values', 'string'))
print repr(testui.config('values', 'bool1'))
print repr(testui.config('values', 'bool2'))
print repr(testui.config('values', 'unknown'))
print "---"
try:
print repr(testui.configbool('values', 'string'))
Matt Mackall
ui: introduce new config parser
r8144 except error.ConfigError, inst:
Thomas Arendsen Hein
Catch illegal boolean values in hgrc nicely....
r4729 print inst
Thomas Arendsen Hein
Allow using default values with ui.configlist, too, and add a test for this.
r2502 print repr(testui.configbool('values', 'bool1'))
print repr(testui.configbool('values', 'bool2'))
print repr(testui.configbool('values', 'bool2', True))
print repr(testui.configbool('values', 'unknown'))
print repr(testui.configbool('values', 'unknown', True))
print "---"
print repr(testui.configlist('lists', 'list1'))
print repr(testui.configlist('lists', 'list2'))
print repr(testui.configlist('lists', 'list3'))
print repr(testui.configlist('lists', 'list4'))
print repr(testui.configlist('lists', 'list4', ['foo']))
print repr(testui.configlist('lists', 'unknown'))
print repr(testui.configlist('lists', 'unknown', ''))
print repr(testui.configlist('lists', 'unknown', 'foo'))
print repr(testui.configlist('lists', 'unknown', ['foo']))
print repr(testui.configlist('lists', 'unknown', 'foo bar'))
print repr(testui.configlist('lists', 'unknown', 'foo, bar'))
print repr(testui.configlist('lists', 'unknown', ['foo bar']))
print repr(testui.configlist('lists', 'unknown', ['foo', 'bar']))
Alexis S. L. Carvalho
allow values that aren't strings in util.configparser
r4069
Matt Mackall
ui: introduce new config parser
r8144 print repr(testui.config('values', 'String'))
Alexis S. L. Carvalho
allow values that aren't strings in util.configparser
r4069
def function():
pass
# values that aren't strings should work
Matt Mackall
ui: introduce new config parser
r8144 testui.setconfig('hook', 'commit', function)
print function == testui.config('hook', 'commit')