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:
@@ -216,9 +216,10 @@ def main():
|
||||
try:
|
||||
parsed, _ = parser.parse_known_args()
|
||||
resource = parsed.resource
|
||||
except Exception as se_except:
|
||||
except Exception:
|
||||
print("Invalid target specified to act upon.\n")
|
||||
parser.print_help()
|
||||
return se_except
|
||||
sys.exit(1)
|
||||
|
||||
if resource in resources:
|
||||
try:
|
||||
|
||||
@@ -95,12 +95,11 @@ class TestSolum(base.TestCase):
|
||||
'.*?^optional arguments'
|
||||
|
||||
]
|
||||
for argstr in ['--help', 'help']:
|
||||
help_text = self.shell(argstr)
|
||||
for r in required:
|
||||
self.assertThat(help_text,
|
||||
matchers.MatchesRegex(r,
|
||||
self.re_options))
|
||||
help_text = self.shell('--help')
|
||||
for r in required:
|
||||
self.assertThat(help_text,
|
||||
matchers.MatchesRegex(r,
|
||||
self.re_options))
|
||||
|
||||
# Assembly Tests #
|
||||
@mock.patch.object(assembly.AssemblyManager, "list")
|
||||
|
||||
Reference in New Issue
Block a user