From: Y Bharath Date: Thu, 27 Feb 2025 16:01:41 +0000 (+0530) Subject: tests: Catch specific exceptions X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=a7e0bfe4e98dd670f4fb1cd1eb61d89c29d8ea9d;p=matthieu%2Ffrr.git tests: Catch specific exceptions Catch specific exceptions and handle them accordingly Signed-off-by: y-bharath14 --- 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)