@@ -54,7 +54,8 @@ def get_all_tested_commands_from_regex(lines):
5454 if re_idx is None and re .findall (CMD_PATTERN [3 ], lines [row_num ]):
5555 re_idx = 3
5656 if re_idx is not None :
57- command = re .findall (CMD_PATTERN [re_idx ], lines [row_num ])[0 ]
57+ matches = re .findall (CMD_PATTERN [re_idx ], lines [row_num ])
58+ command = matches [0 ] if matches else ''
5859 while row_num < total_lines :
5960 if (re_idx in [0 , 1 ] and not re .findall (END_PATTERN , lines [row_num ])) or \
6061 (re_idx == 2 and (row_num + 1 ) < total_lines and
@@ -105,14 +106,17 @@ def search_argument_context(row_num, lines):
105106 # Match `with self.argument_context(scope) as c:`
106107 if ref1 :
107108 sub_pattern = r'for scope in (.*):'
108- cmds = json .loads (
109- re .findall (sub_pattern , lines [row_num - 1 ])[0 ].replace ('\' ' , '"' ))
109+ matches = re .findall (sub_pattern , lines [row_num - 1 ])
110+ if matches :
111+ cmds = json .loads (matches [0 ].replace ('\' ' , '"' ))
110112 break
111113 # Match `with self.argument_context(['"]{} stop['"].format(scope)) as c:',
112114 if ref2 :
113115 sub_pattern = r'for scope in (.*):'
114- format_strings = json .loads (
115- re .findall (sub_pattern , lines [row_num - 1 ])[0 ].replace ('\' ' , '"' ))
116+ format_strings = ''
117+ matches = re .findall (sub_pattern , lines [row_num - 1 ])
118+ if matches :
119+ format_strings = json .loads (matches [0 ].replace ('\' ' , '"' ))
116120 for c in ref2 :
117121 for f in format_strings :
118122 cmds .append (c .replace ('{}' , f ))
0 commit comments