Nir Soffer has uploaded a new change for review. Change subject: tool: Raise UsageError when used incorrectly ......................................................................
tool: Raise UsageError when used incorrectly Commit e5e80540e8 added a new type of error, when user try to configure non existing module. The test for this feature expect a SystemExit exception, but the code was actualy raising a KeyError. Seems that both the test and the code are wrong, so now a UsageError is raised in this case. Change-Id: I8e0528c84b41eee56c141d725c837cf48df5d186 Signed-off-by: Nir Soffer <[email protected]> --- M lib/vdsm/tool/configurator.py M tests/toolTests.py 2 files changed, 4 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/35/31735/1 diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py index 2f71075..7f4dc1a 100644 --- a/lib/vdsm/tool/configurator.py +++ b/lib/vdsm/tool/configurator.py @@ -22,7 +22,7 @@ import sys import traceback -from . import service, expose +from . import service, expose, UsageError from .configurators import \ certificates, \ CONFIGURED, \ @@ -180,7 +180,7 @@ try: requiredNames = _getConfigurers()[next_].getRequires() except KeyError: - raise KeyError( + raise UsageError( "error: argument --module: " "invalid choice: %s (choose from %s)\n" % (next_, modulesNames) ) diff --git a/tests/toolTests.py b/tests/toolTests.py index bdd8a5d..b41ae50 100644 --- a/tests/toolTests.py +++ b/tests/toolTests.py @@ -24,6 +24,7 @@ NOT_SURE from vdsm.tool.configurators.configfile import ConfigFile, ParserWrapper from vdsm.tool.configurators.libvirt import Libvirt +from vdsm.tool import UsageError from vdsm.tool import upgrade from vdsm import utils import monkeypatch @@ -151,7 +152,7 @@ def testNonExistentModule(self): self.assertRaises( - SystemExit, + UsageError, configurator._parse_args, 'validate-config', '--module=b' -- To view, visit http://gerrit.ovirt.org/31735 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8e0528c84b41eee56c141d725c837cf48df5d186 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
