tests/test-trusted.py
changeset 31472 75e4bae56068
parent 30559 d83ca854fa21
child 31857 08fbc97d1364
equal deleted inserted replaced
31471:95be8b7181d3 31472:75e4bae56068
   199 
   199 
   200 try:
   200 try:
   201     testui(debug=True, silent=True)
   201     testui(debug=True, silent=True)
   202 except error.ParseError as inst:
   202 except error.ParseError as inst:
   203     print(inst)
   203     print(inst)
       
   204 
       
   205 print()
       
   206 print('# access typed information')
       
   207 with open('.hg/hgrc', 'w') as f:
       
   208     f.write('''\
       
   209 [foo]
       
   210 sub=main
       
   211 sub:one=one
       
   212 sub:two=two
       
   213 path=monty/python
       
   214 bool=true
       
   215 int=42
       
   216 bytes=81mb
       
   217 list=spam,ham,eggs
       
   218 ''')
       
   219 u = testui(user='abc', group='def', cuser='foo', silent=True)
       
   220 print('# suboptions, trusted and untrusted')
       
   221 trusted = u.configsuboptions('foo', 'sub')
       
   222 untrusted = u.configsuboptions('foo', 'sub', untrusted=True)
       
   223 print(
       
   224     (trusted[0], sorted(trusted[1].items())),
       
   225     (untrusted[0], sorted(untrusted[1].items())))
       
   226 print('# path, trusted and untrusted')
       
   227 print(u.configpath('foo', 'path'), u.configpath('foo', 'path', untrusted=True))
       
   228 print('# bool, trusted and untrusted')
       
   229 print(u.configbool('foo', 'bool'), u.configbool('foo', 'bool', untrusted=True))
       
   230 print('# int, trusted and untrusted')
       
   231 print(
       
   232     u.configint('foo', 'int', 0),
       
   233     u.configint('foo', 'int', 0, untrusted=True))
       
   234 print('# bytes, trusted and untrusted')
       
   235 print(
       
   236     u.configbytes('foo', 'bytes', 0),
       
   237     u.configbytes('foo', 'bytes', 0, untrusted=True))
       
   238 print('# list, trusted and untrusted')
       
   239 print(
       
   240     u.configlist('foo', 'list', []),
       
   241     u.configlist('foo', 'list', [], untrusted=True))