Print meaningul error when invalid target specified and exit

Also adjust test_help accordingly.

Change-Id: Ib209e60937599604cdc60d06199a967aeab8ea11
Fixes-bug: #1309097
This commit is contained in:
Noorul Islam K M
2014-04-18 21:04:10 +05:30
parent 5ec4a86f96
commit 70eedf71c7
2 changed files with 8 additions and 8 deletions

View File

@@ -216,9 +216,10 @@ def main():
try: try:
parsed, _ = parser.parse_known_args() parsed, _ = parser.parse_known_args()
resource = parsed.resource resource = parsed.resource
except Exception as se_except: except Exception:
print("Invalid target specified to act upon.\n")
parser.print_help() parser.print_help()
return se_except sys.exit(1)
if resource in resources: if resource in resources:
try: try:

View File

@@ -95,12 +95,11 @@ class TestSolum(base.TestCase):
'.*?^optional arguments' '.*?^optional arguments'
] ]
for argstr in ['--help', 'help']: help_text = self.shell('--help')
help_text = self.shell(argstr) for r in required:
for r in required: self.assertThat(help_text,
self.assertThat(help_text, matchers.MatchesRegex(r,
matchers.MatchesRegex(r, self.re_options))
self.re_options))
# Assembly Tests # # Assembly Tests #
@mock.patch.object(assembly.AssemblyManager, "list") @mock.patch.object(assembly.AssemblyManager, "list")