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
|
# -*- mode:python; coding:utf-8 -*-
import optparse
import mock
def get_opts():
import atheist.manager
parser = atheist.manager.OptParser()
# FIXME: find other way to test plugin options
# mng = mock.Mock()
# mng.config.pluginpath = []
# api = atheist.manager.Manager.AInternal(mng)
# for plugin in api.plugins:
# plugin.config(mock.Mock(), parser)
return parser.option_list
def parser_opts():
retval = []
for opt in get_opts():
_short = str.join('', opt._short_opts)
_long = opt._long_opts[0]
if opt.metavar:
dest = opt.metavar
elif opt.dest:
dest = opt.dest.upper()
else:
dest = ''
val = ''
if opt.takes_value():
if _short:
val = "%s %s, " % (_short, dest)
val += "%s=%s" % (_long, dest)
else:
if _short:
val = "%s, " % _short
val += _long
# print opt._short_opts, val
retval.append(val)
return retval
def doc_opts():
return ['cmdoption:: %s' % x for x in parser_opts()]
# --help
t = Test('$atheist', expected=1)
t.post += FileContains('ABSOLUTELY NO WARRANTY')
for opt in parser_opts():
t.post += FileContains(opt)
# sphinx documentation
atheist_doc = '$basedir/doc/intro.rst'
t = Test('cat %s' % atheist_doc)
t.pre += FileExists(atheist_doc)
for opt in doc_opts():
t.post += FileContains(opt)
# manpage
man_src = '$basedir/debian/atheist.xml'
man_dst = '$basedir/debian/atheist.1'
t = Test('./debian/rules %s' % man_dst, shell=True, timeout=10)
t.pre += DebPkgInstalled('cdbs')
t.pre += DebPkgInstalled('docbook-xsl')
t.pre += FileExists(man_src)
t.gen += man_dst
t = Test('man %s | cat' % man_dst, shell=True)
for opt in parser_opts():
t.post += FileContains(opt)
|