TT#81700 bin/check.py: fix error when --help command

> root@sp1:/usr/local/devel/kamailio-config-tests# ./bin/check.py -h
> Traceback (most recent call last):
>   File "/usr/local/devel/kamailio-config-tests/./bin/check.py", line 364, in <module>
>     args = parser.parse_args()
>   File "/usr/lib/python3.9/argparse.py", line 1830, in parse_args
>     args, argv = self.parse_known_args(args, namespace)
>   File "/usr/lib/python3.9/argparse.py", line 1863, in parse_known_args
>     namespace, args = self._parse_known_args(args, namespace)
>   File "/usr/lib/python3.9/argparse.py", line 2072, in _parse_known_args
>     start_index = consume_optional(start_index)
>   File "/usr/lib/python3.9/argparse.py", line 2012, in consume_optional
>     take_action(action, args, option_string)
>   File "/usr/lib/python3.9/argparse.py", line 1940, in take_action
>     action(self, namespace, argument_values, option_string)
>   File "/usr/lib/python3.9/argparse.py", line 1104, in __call__
>     parser.print_help()
>   File "/usr/lib/python3.9/argparse.py", line 2560, in print_help
>     self._print_message(self.format_help(), file)
>   File "/usr/lib/python3.9/argparse.py", line 2544, in format_help
>     return formatter.format_help()
>   File "/usr/lib/python3.9/argparse.py", line 295, in format_help
>     help = self._root_section.format_help()
>   File "/usr/lib/python3.9/argparse.py", line 226, in format_help
>     item_help = join([func(*args) for func, args in self.items])
>   File "/usr/lib/python3.9/argparse.py", line 226, in <listcomp>
>     item_help = join([func(*args) for func, args in self.items])
>   File "/usr/lib/python3.9/argparse.py", line 333, in _format_usage
>     action_usage = format(optionals + positionals, groups)
>   File "/usr/lib/python3.9/argparse.py", line 408, in _format_actions_usage
>     start = actions.index(group._group_actions[0])
> IndexError: list index out of range

Change-Id: I6303ab109074589e3483256eae33f43dc7c75c19
mr11.2
Victor Seva 4 years ago
parent 607a58e3cb
commit c64c276c34

@ -36,7 +36,7 @@ except ImportError:
class XAvp:
""" Class to simulate the xavp """
"""Class to simulate the xavp"""
def __init__(self, name, data):
result = re.match(r"\$xavp\((\w+)\)", name)
@ -112,22 +112,22 @@ class Section(Flag):
class Test:
""" Class to create TAP output """
"""Class to create TAP output"""
def __init__(self):
self._step = []
self._errflag = Section(0)
def comment(self, msg):
""" Add a comment """
"""Add a comment"""
self._step.append({"result": None, "msg_ok": msg})
def ok(self, msg=None):
""" Add a ok result """
"""Add a ok result"""
self._step.append({"result": True, "msg_ok": msg})
def error(self, section, msg_err):
""" Add an error result"""
"""Add an error result"""
self._step.append({"result": False, "msg_err": msg_err})
self._errflag |= section
@ -163,7 +163,7 @@ class Test:
return result
def test(self, section, value_expected, value, msg_err, msg_ok=None):
""" Test two values and add the result"""
"""Test two values and add the result"""
result = Test.compare(value_expected, value)
val = {"result": result, "msg_err": msg_err, "msg_ok": msg_ok}
self._step.append(val)
@ -201,7 +201,7 @@ class Test:
def check_flow_vars(sk, sv, cv, test):
""" check the vars on a flow level"""
"""check the vars on a flow level"""
sec = Section.FLOW_VARS
for k in sv.keys():
logging.debug("check k:'%s'" % k)
@ -247,7 +247,7 @@ def check_flow_vars(sk, sv, cv, test):
def check_flow(scen, check, test):
""" checks the flow and the vars inside"""
"""checks the flow and the vars inside"""
sec = Section.FLOW
for i in range(len(scen)):
(sk, sv) = scen[i].popitem()
@ -357,7 +357,6 @@ def main(args):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="generate TAP result")
grp = parser.add_mutually_exclusive_group()
parser.add_argument("test_yaml_file", help="YAML file with checks")
parser.add_argument("kam_file", help="JSON cfgt kamailio file")
parser.add_argument("-d", "--debug", action="store_true")

Loading…
Cancel
Save