comparison tests/test-ui-config.py @ 8449:807f3f5c60e9

tests: renamed Python tests to .py
author Martin Geisler <mg@lazybytes.net>
date Sun, 17 May 2009 01:39:31 +0200
parents tests/test-ui-config@fca54469480e
children 284fda4cd093
comparison
equal deleted inserted replaced
8448:0eb8c4df61bd 8449:807f3f5c60e9
1 #!/usr/bin/env python
2
3 from mercurial import ui, util, dispatch, error
4
5 testui = ui.ui()
6 parsed = dispatch._parseconfig(testui, [
7 'values.string=string value',
8 'values.bool1=true',
9 'values.bool2=false',
10 'lists.list1=foo',
11 'lists.list2=foo bar baz',
12 'lists.list3=alice, bob',
13 'lists.list4=foo bar baz alice, bob',
14 ])
15
16 print repr(testui.configitems('values'))
17 print repr(testui.configitems('lists'))
18 print "---"
19 print repr(testui.config('values', 'string'))
20 print repr(testui.config('values', 'bool1'))
21 print repr(testui.config('values', 'bool2'))
22 print repr(testui.config('values', 'unknown'))
23 print "---"
24 try:
25 print repr(testui.configbool('values', 'string'))
26 except error.ConfigError, inst:
27 print inst
28 print repr(testui.configbool('values', 'bool1'))
29 print repr(testui.configbool('values', 'bool2'))
30 print repr(testui.configbool('values', 'bool2', True))
31 print repr(testui.configbool('values', 'unknown'))
32 print repr(testui.configbool('values', 'unknown', True))
33 print "---"
34 print repr(testui.configlist('lists', 'list1'))
35 print repr(testui.configlist('lists', 'list2'))
36 print repr(testui.configlist('lists', 'list3'))
37 print repr(testui.configlist('lists', 'list4'))
38 print repr(testui.configlist('lists', 'list4', ['foo']))
39 print repr(testui.configlist('lists', 'unknown'))
40 print repr(testui.configlist('lists', 'unknown', ''))
41 print repr(testui.configlist('lists', 'unknown', 'foo'))
42 print repr(testui.configlist('lists', 'unknown', ['foo']))
43 print repr(testui.configlist('lists', 'unknown', 'foo bar'))
44 print repr(testui.configlist('lists', 'unknown', 'foo, bar'))
45 print repr(testui.configlist('lists', 'unknown', ['foo bar']))
46 print repr(testui.configlist('lists', 'unknown', ['foo', 'bar']))
47
48 print repr(testui.config('values', 'String'))
49
50 def function():
51 pass
52
53 # values that aren't strings should work
54 testui.setconfig('hook', 'commit', function)
55 print function == testui.config('hook', 'commit')