tests/test-ui-config
changeset 4069 3fef134832d8
parent 3346 1700a103458e
child 4549 0c61124ad877
equal deleted inserted replaced
4068:5b1f663ef86d 4069:3fef134832d8
     1 #!/usr/bin/env python
     1 #!/usr/bin/env python
     2 
     2 
       
     3 import ConfigParser
     3 from mercurial import ui, util, commands
     4 from mercurial import ui, util, commands
     4 
     5 
     5 testui = ui.ui()
     6 testui = ui.ui()
     6 parsed = commands.parseconfig([
     7 parsed = commands.parseconfig([
     7     'values.string=string value',
     8     'values.string=string value',
    68 try:
    69 try:
    69     print repr(testui.config('interpolation', 'value5'))
    70     print repr(testui.config('interpolation', 'value5'))
    70 except util.Abort, inst:
    71 except util.Abort, inst:
    71     print inst
    72     print inst
    72 print "---"
    73 print "---"
       
    74 
       
    75 cp = util.configparser()
       
    76 cp.add_section('foo')
       
    77 cp.set('foo', 'bar', 'baz')
       
    78 try:
       
    79     # should fail - keys are case-sensitive
       
    80     cp.get('foo', 'Bar')
       
    81 except ConfigParser.NoOptionError, inst:
       
    82     print inst
       
    83 
       
    84 def function():
       
    85     pass
       
    86 
       
    87 cp.add_section('hook')
       
    88 # values that aren't strings should work
       
    89 cp.set('hook', 'commit', function)
       
    90 f = cp.get('hook', 'commit')
       
    91 print "f %s= function" % (f == function and '=' or '!')