1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# vim: set fileencoding=utf-8 :
"""
Test L{gbp.config.GbpOptionParser}
Test L{gbp.config.GbpOptionParserDebian}
"""
from . import context
def test_option_parser():
"""
Methods tested:
- L{gbp.config.GbpOptionParser.add_config_file_option}
- L{gbp.config.GbpOptionParser.add_boolean_config_file_option}
>>> import gbp.config
>>> c = gbp.config.GbpOptionParser('common', prefix='test')
>>> c.add_config_file_option(option_name='upstream-branch', dest='upstream')
>>> c.add_boolean_config_file_option(option_name='overlay', dest='overlay')
>>> c.add_boolean_config_file_option(option_name='track', dest='track')
"""
def test_option_parser_debian():
"""
Methods tested:
- L{gbp.config.GbpOptionParserDebian.add_config_file_option}
>>> import gbp.config
>>> c = gbp.config.GbpOptionParserDebian('debian')
>>> c.add_config_file_option(option_name='builder', dest='builder')
Traceback (most recent call last):
...
KeyError: 'builder'
>>> c.add_config_file_option(option_name='builder', dest='builder', help='foo')
"""
def test_option_group():
"""
Methods tested:
- L{gbp.config.GbpOptionGroup.add_config_file_option}
- L{gbp.config.GbpOptionGroup.add_boolean_config_file_option}
>>> import gbp.config
>>> c = gbp.config.GbpOptionParser('debian')
>>> g = gbp.config.GbpOptionGroup(c, 'wheezy')
>>> g.add_config_file_option(option_name='debian-branch', dest='branch')
>>> g.add_boolean_config_file_option(option_name='track', dest='track')
"""
def test_tristate():
"""
Methods tested:
- L{gbp.config.GbpOptionParser.add_config_file_option}
>>> import gbp.config
>>> c = gbp.config.GbpOptionParser('tristate')
>>> c.add_config_file_option(option_name="color", dest="color", type='tristate')
>>> options, args= c.parse_args(['--color=auto'])
>>> options.color
auto
"""
def test_parser_fallback():
"""
Make sure we also parse git-<subcommands> sections if
gbp <subcommand> was used.
>>> import os
>>> from gbp.config import GbpOptionParser
>>> parser = GbpOptionParser('foo')
>>> tmpdir = str(context.new_tmpdir('foo'))
>>> confname = os.path.join(tmpdir, 'gbp.conf')
>>> parser.config_files = [confname]
>>> f = file(confname, 'w')
>>> f.write('[foo]\\nthere = is\\n[git-foo]\\nno = truth\\n')
>>> f.close()
>>> parser._parse_config_files()
>>> parser.config['there']
'is'
>>> parser.config['no']
'truth'
"""
def test_filter():
"""
The filter option should always parse as a list
>>> import os
>>> from gbp.config import GbpOptionParser
>>> parser = GbpOptionParser('bar')
>>> tmpdir = str(context.new_tmpdir('bar'))
>>> confname = os.path.join(tmpdir, 'gbp.conf')
>>> parser.config_files = [confname]
>>> f = file(confname, 'w')
>>> f.write('[bar]\\nfilter = asdf\\n')
>>> f.close()
>>> parser._parse_config_files()
>>> parser.config['filter']
['asdf']
>>> f = file(confname, 'w')
>>> f.write("[bar]\\nfilter = ['this', 'is', 'a', 'list']\\n")
>>> f.close()
>>> parser._parse_config_files()
>>> parser.config['filter']
['this', 'is', 'a', 'list']
"""
|