From 7257cf442f4e1bf30c963b42ba98f91b6d405d8a Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Thu, 6 Jun 2024 21:32:09 +0530 Subject: [PATCH] Updated the tresult with info/err message --- lib/jnpr/jsnapy/operator.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/jnpr/jsnapy/operator.py b/lib/jnpr/jsnapy/operator.py index 5b16ce4..dd67ffd 100755 --- a/lib/jnpr/jsnapy/operator.py +++ b/lib/jnpr/jsnapy/operator.py @@ -117,6 +117,15 @@ def _print_result(self, testmssg, result): self.logger_testop.info( colorama.Fore.GREEN + "PASS | " + testmssg, extra=self.log_detail ) + def _print_mssg(self, testmssg, result): + if result is False: + self.logger_testop.info( + colorama.Fore.RED + "FAIL | " + testmssg, extra=self.log_detail + ) + elif result is True: + self.logger_testop.info( + colorama.Fore.GREEN + "PASS | " + testmssg, extra=self.log_detail + ) def print_testmssg(self, testname): """ @@ -420,7 +429,7 @@ def exists( % (element, x_path, count_pass, count_fail) ) self._print_result(msg, res) - self._print_result(err_mssg, res) + self._print_mssg(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 ]' % ( @@ -429,7 +438,7 @@ def exists( count_pass, ) self._print_result(msg, res) - self._print_result(info_mssg, res) + self._print_mssg(info_mssg, res) tresult["info"] = info_mssg # Updating the user specified info message # tresult['info'] = info_mssg