Make tox run doctests
Use 'nosetests --with-doctests' to run any doctests found. We currently only use doctests in a handful of places, but we may as well run them to ensure they work. Make the cfg doctests avoid using the global CONF since we would need to reset its state between each doctest. Fix the cliutils doctests to actually pass. Use 'nosetests --exclude-dir=tests/testmods' to avoid loading the modules from this dir while discovering doctests. The cfg unit tests rely on these modules not having been previously loaded. Change-Id: I19ad70767fa5c8352b994dc963b5d3a7c9d9eb95
This commit is contained in:
parent
2f93ad27a2
commit
580c259b39
@ -236,10 +236,11 @@ in order to support a common usage pattern in OpenStack::
|
||||
Positional command line arguments are supported via a 'positional' Opt
|
||||
constructor argument::
|
||||
|
||||
>>> CONF.register_cli_opt(MultiStrOpt('bar', positional=True))
|
||||
>>> conf = ConfigOpts()
|
||||
>>> conf.register_cli_opt(MultiStrOpt('bar', positional=True))
|
||||
True
|
||||
>>> CONF(['a', 'b'])
|
||||
>>> CONF.bar
|
||||
>>> conf(['a', 'b'])
|
||||
>>> conf.bar
|
||||
['a', 'b']
|
||||
|
||||
It is also possible to use argparse "sub-parsers" to parse additional
|
||||
@ -249,10 +250,11 @@ command line arguments using the SubCommandOpt class:
|
||||
... list_action = subparsers.add_parser('list')
|
||||
... list_action.add_argument('id')
|
||||
...
|
||||
>>> CONF.register_cli_opt(SubCommandOpt('action', handler=add_parsers))
|
||||
>>> conf = ConfigOpts()
|
||||
>>> conf.register_cli_opt(SubCommandOpt('action', handler=add_parsers))
|
||||
True
|
||||
>>> CONF(['list', '10'])
|
||||
>>> CONF.action.name, CONF.action.id
|
||||
>>> conf(args=['list', '10'])
|
||||
>>> conf.action.name, conf.action.id
|
||||
('list', '10')
|
||||
|
||||
"""
|
||||
|
@ -36,11 +36,11 @@ def validate_args(fn, *args, **kwargs):
|
||||
>>> validate_args(lambda a: None)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
MissingArgs: An argument is missing: a
|
||||
MissingArgs: An argument is missing
|
||||
>>> validate_args(lambda a, b, c, d: None, 0, c=1)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
MissingArgs: 2 arguments are missing: b, d
|
||||
MissingArgs: 2 arguments are missing
|
||||
|
||||
:param fn: the function to check
|
||||
:param arg: the positional arguments supplied
|
||||
|
2
tox.ini
2
tox.ini
@ -11,7 +11,7 @@ setenv = VIRTUAL_ENV={envdir}
|
||||
NOSE_OPENSTACK_STDOUT=1
|
||||
deps = -r{toxinidir}/tools/pip-requires
|
||||
-r{toxinidir}/tools/test-requires
|
||||
commands = nosetests {posargs}
|
||||
commands = nosetests --with-doctest --exclude-dir=tests/testmods {posargs}
|
||||
|
||||
[testenv:pep8]
|
||||
deps = pep8==1.3.3
|
||||
|
Loading…
Reference in New Issue
Block a user