From a7e0bfe4e98dd670f4fb1cd1eb61d89c29d8ea9d Mon Sep 17 00:00:00 2001 From: Y Bharath Date: Thu, 27 Feb 2025 21:31:41 +0530 Subject: [PATCH] tests: Catch specific exceptions Catch specific exceptions and handle them accordingly Signed-off-by: y-bharath14 --- tests/topotests/lib/common_check.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/topotests/lib/common_check.py b/tests/topotests/lib/common_check.py index b04b9de44e..50819c9c70 100644 --- a/tests/topotests/lib/common_check.py +++ b/tests/topotests/lib/common_check.py @@ -19,7 +19,7 @@ def ip_check_path_selection( cmdstr = f"show ip route {ipaddr_str} json" try: output = json.loads(router.vtysh_cmd(cmdstr)) - except: + except (json.JSONDecodeError, ValueError): output = {} ret = topotest.json_cmp(output, expected) @@ -59,7 +59,7 @@ def iproute2_check_path_selection(router, ipaddr_str, expected, vrf_name=None): cmdstr = f"ip -json route show {ipaddr_str}" try: output = json.loads(router.cmd(cmdstr)) - except: + except (json.JSONDecodeError, ValueError): output = [] return topotest.json_cmp(output, expected) -- 2.39.5