Initialize 'result' variable in functional.base

Initialize 'result' variable as None in the method of
functional.base.BaseTestCase.openstack to avoid UnboundLocalError
when exception is raised.

Change-Id: Id324d1b4395b23dfe7eb5e9d977c67ce6dbc22f7
Closes-bug: 1762717
This commit is contained in:
Yikun Jiang 2018-04-10 20:18:55 +08:00
parent 16bb97c779
commit 006f1eb6d0
1 changed files with 2 additions and 1 deletions

View File

@ -26,6 +26,7 @@ class BaseTestCase(base.BaseTestCase):
@classmethod
def openstack(cls, cmd, may_fail=False, use_json=False):
result = None
try:
to_exec = ['openstack'] + cmd.split()
if use_json:
@ -41,7 +42,7 @@ class BaseTestCase(base.BaseTestCase):
if not may_fail:
raise
if use_json:
if use_json and result:
return json.loads(result)
else:
return result