summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2013-01-14 08:38:17 +0000
committerMark McLoughlin <markmc@redhat.com>2013-01-15 16:45:25 +0000
commit580c259b39fa5e639d3fbe00dc24da09c11d282a (patch)
tree3575cb70dbb1a433ad375de27b188552e352fbbd
parent2f93ad27a25e10df47a4181938e3a183fc899954 (diff)
downloadoslo-580c259b39fa5e639d3fbe00dc24da09c11d282a.tar.gz
oslo-580c259b39fa5e639d3fbe00dc24da09c11d282a.tar.xz
oslo-580c259b39fa5e639d3fbe00dc24da09c11d282a.zip
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
-rw-r--r--openstack/common/cfg.py14
-rw-r--r--openstack/common/cliutils.py4
-rw-r--r--tox.ini2
3 files changed, 11 insertions, 9 deletions
diff --git a/openstack/common/cfg.py b/openstack/common/cfg.py
index a6500eb..8c965c1 100644
--- a/openstack/common/cfg.py
+++ b/openstack/common/cfg.py
@@ -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')
"""
diff --git a/openstack/common/cliutils.py b/openstack/common/cliutils.py
index 89a6f62..411bd58 100644
--- a/openstack/common/cliutils.py
+++ b/openstack/common/cliutils.py
@@ -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
diff --git a/tox.ini b/tox.ini
index 6efcecc..483c545 100644
--- a/tox.ini
+++ b/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