diff tests/test-ui-config @ 2502:18cf95ad3666

Allow using default values with ui.configlist, too, and add a test for this.
author Thomas Arendsen Hein <thomas@intevation.de>
date Mon, 26 Jun 2006 22:44:48 +0200
parents
children 24c1db20990c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-ui-config	Mon Jun 26 22:44:48 2006 +0200
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+from mercurial import ui
+
+testui = ui.ui()
+testui.updateopts(config=[
+    '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'))
+except ValueError, why:
+    print why
+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']))
+print "---"