diff --git a/lib/jnpr/jsnapy/operator.py b/lib/jnpr/jsnapy/operator.py index bda8aaa1..156a7076 100755 --- a/lib/jnpr/jsnapy/operator.py +++ b/lib/jnpr/jsnapy/operator.py @@ -40,7 +40,6 @@ def testname_results(self): test["command"] = cmd testname_result_dict.setdefault(test["test_name"], []) testname_result_dict[test["test_name"]].append(test) - del test["test_name"] return testname_result_dict def define_operator( @@ -118,6 +117,16 @@ def _print_result(self, testmssg, result): colorama.Fore.GREEN + "PASS | " + testmssg, extra=self.log_detail ) + def _print_msg(self, testmssg, result): + if result is False: + self.logger_testop.info( + colorama.Fore.RED + "FAIL | " + testmssg, extra=self.log_detail + ) + else: + self.logger_testop.info( + colorama.Fore.GREEN + "PASS | " + testmssg, extra=self.log_detail + ) + def print_testmssg(self, testname): """ Print info and error messages @@ -420,6 +429,8 @@ def exists( % (element, x_path, count_pass, count_fail) ) self._print_result(msg, res) + self._print_msg(err_mssg, res) + tresult["err"] = err_mssg # Updating the user specified err message elif res is True: msg = 'All "%s" exists at xpath "%s" [ %d value matched ]' % ( element, @@ -427,6 +438,8 @@ def exists( count_pass, ) self._print_result(msg, res) + self._print_msg(info_mssg, res) + tresult["info"] = info_mssg # Updating the user specified info message # tresult['info'] = info_mssg # tresult['err'] = err_mssg diff --git a/tools/jsnap2py b/tools/jsnap2py index 8baa9bae..860a6fdb 100755 --- a/tools/jsnap2py +++ b/tools/jsnap2py @@ -27,7 +27,7 @@ def msg_change(x): data = (data[0],data[1][1:]) if data[0] in ['id', 'ID']: data = (data[0], int(data[1])-1) - msg = "{{%s_%s}}" % (data) + msg = "{{%s_%s}}" % (data) elif data[0] in ['PRE', 'POST']: msg = '{{%s["%s"]}}' % (data) else: @@ -120,7 +120,7 @@ else: '\$id\.\d|\$pre\s?/?\.?/\s?[\w-]+/?[\w-]*|\$post\s?/?\.?/\s?[\w-]+/?[\w-]*|,\s?\.{0,2}/?\.{0,2}/?[\w-]+/?[\w-]*/?[\w-]*', data.group(2), re.I) - inputs = map(msg_change, inputs) + inputs = list(map(msg_change, inputs)) to_format = re.search('"(.*?)"', obj.group(2)) if len(inputs) > 0: if to_format: