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:
|
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:
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|||||||
Reference in New Issue
Block a user