From d7d21c3a190f7754afe4d5b969501756a3739e48 Mon Sep 17 00:00:00 2001 From: Christian Hopps Date: Thu, 29 Jul 2021 11:07:01 +0000 Subject: [PATCH] tests: fix pylint test errors Signed-off-by: Christian Hopps --- .../test_bgp_basic_functionality.py | 2 + .../test_bgp_communities.py | 54 +++++--- .../test_bgp_communities_topo2.py | 18 +-- .../bgp_ecmp_topo1/test_bgp_ecmp_topo1.py | 1 + .../scripts/notification_check.py | 2 +- .../scripts/scale_down.py | 2 +- .../bgp_l3vpn_to_bgp_vrf/scripts/scale_up.py | 2 +- .../test_bgp_l3vpn_to_bgp_vrf.py | 30 ----- .../scripts/adjacencies.py | 2 + .../test_bgp_aggregation.py | 117 +++++++++++------- .../bgp_route_map/test_route_map_topo2.py | 80 ++++++++---- .../test_bgp_vrf_dynamic_route_leak_topo1.py | 3 +- .../test_bgp_vrf_dynamic_route_leak_topo2.py | 2 +- .../test_evpn_type5_chaos_topo1.py | 29 +++-- .../test_evpn_type5_topo1.py | 48 +++---- .../isis_lfa_topo1/test_isis_lfa_topo1.py | 2 +- .../isis_rlfa_topo1/test_isis_rlfa_topo1.py | 2 +- tests/topotests/isis_snmp/test_isis_snmp.py | 2 +- .../isis_sr_te_topo1/test_isis_sr_te_topo1.py | 2 +- tests/topotests/isis_topo1/test_isis_topo1.py | 3 +- .../isis_topo1_vrf/test_isis_topo1_vrf.py | 3 +- tests/topotests/ldp_topo1/test_ldp_topo1.py | 2 +- .../test_mcast_pim_bsmp_01.py | 13 +- .../test_multicast_pim_sm_topo1.py | 41 +++--- .../test_multicast_pim_sm_topo4.py | 30 +++-- .../test_multicast_pim_static_rp.py | 6 +- tests/topotests/nhrp_topo/test_nhrp_topo.py | 8 +- .../ospf6_topo1_vrf/test_ospf6_topo1_vrf.py | 4 +- .../test_ospf_p2mp.py | 4 +- tests/topotests/pim_acl/test_pim_acl.py | 3 +- tests/topotests/pim_igmp_vrf/test_pim_vrf.py | 3 + 31 files changed, 300 insertions(+), 220 deletions(-) diff --git a/tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py b/tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py index e3f07166f9..b9ad57f8bc 100644 --- a/tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py +++ b/tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py @@ -40,6 +40,8 @@ Test steps - Verify routes not installed in zebra when /32 routes received with loopback BGP session subnet """ +# XXX clean up in later commit to avoid conflict on rebase +# pylint: disable=C0413 import os import sys diff --git a/tests/topotests/bgp_communities_topo1/test_bgp_communities.py b/tests/topotests/bgp_communities_topo1/test_bgp_communities.py index f52f539afb..df579bc012 100644 --- a/tests/topotests/bgp_communities_topo1/test_bgp_communities.py +++ b/tests/topotests/bgp_communities_topo1/test_bgp_communities.py @@ -340,14 +340,18 @@ def test_bgp_no_advertise_community_p0(request): ) result = verify_bgp_rib(tgen, addr_type, dut, input_dict, expected=False) - assert result is not True, "Testcase {} : Failed \n " - " Routes still present in R3 router. Error: {}".format(tc_name, result) + assert result is not True, "Testcase {} : Failed \n ".format( + tc_name + ) + " Routes still present in R3 router. Error: {}".format(result) result = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n " - " Routes still present in R3 router. Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format( + tc_name, result + ) step("Remove and Add no advertise community") # Configure neighbor for route map @@ -392,12 +396,18 @@ def test_bgp_no_advertise_community_p0(request): ) result = verify_bgp_rib(tgen, addr_type, dut, input_dict) - assert result is True, "Testcase {} : Failed \n " - " Routes still present in R3 router. Error: {}".format(tc_name, result) + assert ( + result is True + ), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format( + tc_name, result + ) result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, "Testcase {} : Failed \n " - " Routes still present in R3 router. Error: {}".format(tc_name, result) + assert ( + result is True + ), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format( + tc_name, result + ) step("Repeat above steps when IBGP nbr configured between R1, R2 & R2, R3") topo1 = deepcopy(topo) @@ -579,12 +589,18 @@ def test_bgp_no_advertise_community_p0(request): ) result = verify_bgp_rib(tgen, addr_type, dut, input_dict) - assert result is True, "Testcase {} : Failed \n " - " Routes still present in R3 router. Error: {}".format(tc_name, result) + assert ( + result is True + ), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format( + tc_name, result + ) result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, "Testcase {} : Failed \n " - " Routes still present in R3 router. Error: {}".format(tc_name, result) + assert ( + result is True + ), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format( + tc_name, result + ) step("Remove and Add no advertise community") # Configure neighbor for route map @@ -629,12 +645,18 @@ def test_bgp_no_advertise_community_p0(request): ) result = verify_bgp_rib(tgen, addr_type, dut, input_dict) - assert result is True, "Testcase {} : Failed \n " - " Routes still present in R3 router. Error: {}".format(tc_name, result) + assert ( + result is True + ), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format( + tc_name, result + ) result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, "Testcase {} : Failed \n " - " Routes still present in R3 router. Error: {}".format(tc_name, result) + assert ( + result is True + ), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format( + tc_name, result + ) write_test_footer(tc_name) diff --git a/tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py b/tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py index 24dc6bb487..d18e65bd66 100644 --- a/tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py +++ b/tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py @@ -292,7 +292,7 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request): input_dict_4, next_hop=topo["routers"]["r1"]["links"]["r2"][addr_type].split("/")[0], ) - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) @@ -311,7 +311,7 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request): 0 ], ) - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) else: @@ -330,7 +330,7 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request): ], expected=False, ) - assert result is not True, "Testcase : Failed \n Error: {}".format( + assert result is not True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) @@ -358,7 +358,9 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request): } } result = create_router_bgp(tgen, topo, input_dict_2) - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) step("Configure redistribute static") input_dict_2 = { @@ -376,7 +378,9 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request): } } result = create_router_bgp(tgen, topo, input_dict_2) - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) step( "Verify that these prefixes, originated on R1, are now" @@ -402,7 +406,7 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request): input_dict_4, next_hop=topo["routers"]["r1"]["links"]["r2"][addr_type].split("/")[0], ) - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) @@ -413,7 +417,7 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request): input_dict_4, next_hop=topo["routers"]["r1"]["links"]["r3"][addr_type].split("/")[0], ) - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) diff --git a/tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py b/tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py index dea2ffbd8f..841a766197 100644 --- a/tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py +++ b/tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py @@ -119,6 +119,7 @@ def setup_module(module): def teardown_module(module): + del module tgen = get_topogen() tgen.stop_topology() diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/notification_check.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/notification_check.py index dd2e24722f..73cd08fbe3 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/notification_check.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/notification_check.py @@ -1,4 +1,4 @@ -from lib.lutil import luCommand +from lib.lutil import luCommand, luLast rtrs = ["ce1", "ce2", "ce3", "r1", "r2", "r3", "r4"] for rtr in rtrs: diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py index 6ce81baf11..36be926227 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py @@ -1,4 +1,4 @@ -from lib.lutil import luCommand +from lib.lutil import luCommand, luLast ret = luCommand( "ce1", diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_up.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_up.py index 04ca03973d..9f100b7c30 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_up.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_up.py @@ -1,4 +1,4 @@ -from lib.lutil import luCommand +from lib.lutil import luCommand, luLast num = 50000 b = int(num / (256 * 256)) diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py index 8bb700235c..3844b5ef81 100755 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py @@ -93,16 +93,6 @@ def test_check_linux_mpls(): ltemplateTest("scripts/check_linux_mpls.py", False, CliOnFail, CheckFunc) -def test_notification_check(): - CliOnFail = None - # For debugging, uncomment the next line - # CliOnFail = 'tgen.mininet_cli' - CheckFunc = "ltemplateVersionCheck('4.1', iproute2='4.9')" - # uncomment next line to start cli *before* script is run - # CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')' - ltemplateTest("scripts/notification_check.py", False, CliOnFail, CheckFunc) - - def test_check_scale_up(): CliOnFail = None # For debugging, uncomment the next line @@ -113,16 +103,6 @@ def test_check_scale_up(): ltemplateTest("scripts/scale_up.py", False, CliOnFail, CheckFunc) -def test_notification_check(): - CliOnFail = None - # For debugging, uncomment the next line - # CliOnFail = 'tgen.mininet_cli' - CheckFunc = "ltemplateVersionCheck('4.1', iproute2='4.9')" - # uncomment next line to start cli *before* script is run - # CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')' - ltemplateTest("scripts/notification_check.py", False, CliOnFail, CheckFunc) - - def test_check_scale_down(): CliOnFail = None # For debugging, uncomment the next line @@ -133,16 +113,6 @@ def test_check_scale_down(): ltemplateTest("scripts/scale_down.py", False, CliOnFail, CheckFunc) -def test_notification_check(): - CliOnFail = None - # For debugging, uncomment the next line - # CliOnFail = 'tgen.mininet_cli' - CheckFunc = "ltemplateVersionCheck('4.1', iproute2='4.9')" - # uncomment next line to start cli *before* script is run - # CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')' - ltemplateTest("scripts/notification_check.py", False, CliOnFail, CheckFunc) - - def SKIP_test_cleanup_all(): CliOnFail = None # For debugging, uncomment the next line diff --git a/tests/topotests/bgp_rfapi_basic_sanity/scripts/adjacencies.py b/tests/topotests/bgp_rfapi_basic_sanity/scripts/adjacencies.py index 6ad3e735ee..9878cdc877 100644 --- a/tests/topotests/bgp_rfapi_basic_sanity/scripts/adjacencies.py +++ b/tests/topotests/bgp_rfapi_basic_sanity/scripts/adjacencies.py @@ -1,3 +1,5 @@ +from lib.lutil import luCommand + luCommand( "r1", "ping 2.2.2.2 -c 1", " 0. packet loss", "wait", "PE->P2 (loopback) ping", 60 ) diff --git a/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py b/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py index 04a66d0e25..8297085ffe 100644 --- a/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py +++ b/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py @@ -242,7 +242,9 @@ def test_route_summarisation_with_summary_only_p1(request): step("Configuring {} static routes on router R1 ".format(addr_type)) result = create_static_routes(tgen, input_static) - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) step( "Configuring redistribute static for {} address-family on router R1 ".format( @@ -273,7 +275,9 @@ def test_route_summarisation_with_summary_only_p1(request): } result = verify_rib(tgen, addr_type, "r3", input_static) - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) step("Advertise some prefixes using network command") step( @@ -358,7 +362,9 @@ def test_route_summarisation_with_summary_only_p1(request): } result = verify_rib(tgen, addr_type, "r3", input_advertise) - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) step("Configure aggregate-address to summarise all the advertised routes.") @@ -413,22 +419,28 @@ def test_route_summarisation_with_summary_only_p1(request): } result = verify_rib(tgen, addr_type, "r3", input_static_agg, protocol="bgp") - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) result = verify_rib( tgen, addr_type, "r3", input_static, protocol="bgp", expected=False ) assert ( result is not True - ), "Testcase : Failed \n " "Routes are still present \n Error: {}".format( + ), "Testcase {} : Failed \n " "Routes are still present \n Error: {}".format( tc_name, result ) result = verify_rib(tgen, addr_type, "r1", input_static_agg, protocol="bgp") - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) result = verify_rib(tgen, addr_type, "r1", input_static) - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) for action, value in zip(["removed", "add"], [True, False]): @@ -454,7 +466,7 @@ def test_route_summarisation_with_summary_only_p1(request): } result = create_static_routes(tgen, input_static) - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) @@ -481,18 +493,19 @@ def test_route_summarisation_with_summary_only_p1(request): result = verify_rib( tgen, addr_type, "r1", input_static_1, expected=False ) - assert result is not True, ( - "Testcase : Failed \n " - "Routes are still present \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \n Routes are still present \n Error: {}".format( + tc_name, result ) else: result = verify_rib(tgen, addr_type, "r1", input_static_1) - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) result = verify_rib(tgen, addr_type, "r3", input_static_2, protocol="bgp") - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) @@ -579,17 +592,17 @@ def test_route_summarisation_with_summary_only_p1(request): tgen, addr_type, "r1", input_advertise_1, expected=False ) assert result is not True, ( - "Testcase : Failed \n " + "Testcase {} : Failed \n " "Routes are still present \n Error: {}".format(tc_name, result) ) else: result = verify_bgp_rib(tgen, addr_type, "r1", input_advertise_1) - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) result = verify_rib(tgen, addr_type, "r3", input_advertise_2) - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) @@ -608,7 +621,9 @@ def test_route_summarisation_with_summary_only_p1(request): } result = create_static_routes(tgen, input_static) - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) for addr_type in ADDR_TYPES: input_advertise = { @@ -645,7 +660,9 @@ def test_route_summarisation_with_summary_only_p1(request): input_static = {"r1": {"static_routes": [{"network": AGGREGATE_NW[addr_type]}]}} result = verify_rib(tgen, addr_type, "r3", input_static, protocol="bgp") - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) input_advertise_2 = { "r1": { @@ -669,7 +686,9 @@ def test_route_summarisation_with_summary_only_p1(request): } result = verify_rib(tgen, addr_type, "r3", input_advertise_2, protocol="bgp") - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) for action, value in zip(["Delete", "Re-add"], [True, False]): step("{} aggregation command from R1.".format(action)) @@ -715,30 +734,28 @@ def test_route_summarisation_with_summary_only_p1(request): result = verify_rib( tgen, addr_type, "r1", input_static_agg, expected=False ) - assert result is not True, ( - "Testcase : Failed \n " - "Aggregated route is still present \n Error: {}".format( - tc_name, result - ) + assert ( + result is not True + ), "Testcase {} : Failed \n Aggregated route is still present \n Error: {}".format( + tc_name, result ) result = verify_rib( tgen, addr_type, "r3", input_static_agg, expected=False ) - assert result is not True, ( - "Testcase : Failed \n " - "Aggregated route is still present \n Error: {}".format( - tc_name, result - ) + assert ( + result is not True + ), "Testcase {} : Failed \n Aggregated route is still present \n Error: {}".format( + tc_name, result ) else: result = verify_rib(tgen, addr_type, "r1", input_static_agg) - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) result = verify_rib(tgen, addr_type, "r3", input_static_agg) - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) @@ -793,7 +810,9 @@ def test_route_summarisation_with_as_set_p1(request): step("Configuring {} static routes on router R1 ".format(addr_type)) result = create_static_routes(tgen, input_static) - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) step( "Configuring redistribute static for {} address-family on router R1 ".format( @@ -826,7 +845,9 @@ def test_route_summarisation_with_as_set_p1(request): } result = verify_rib(tgen, addr_type, "r3", input_static) - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) step( "Configure a route-map to attach a unique community attribute value " @@ -977,7 +998,9 @@ def test_route_summarisation_with_as_set_p1(request): } result = create_static_routes(tgen, input_static) - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) step( "Verify on R3 that whenever we remove the static routes, we still" @@ -1017,7 +1040,9 @@ def test_route_summarisation_with_as_set_p1(request): } result = create_static_routes(tgen, input_static) - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result + ) for addr_type in ADDR_TYPES: for ( @@ -1134,30 +1159,28 @@ def test_route_summarisation_with_as_set_p1(request): result = verify_rib( tgen, addr_type, "r1", input_static_agg, expected=False ) - assert result is not True, ( - "Testcase : Failed \n " - "Aggregated route is still present \n Error: {}".format( - tc_name, result - ) + assert ( + result is not True + ), "Testcase {} : Failed \n Aggregated route is still present \n Error: {}".format( + tc_name, result ) result = verify_rib( tgen, addr_type, "r3", input_static_agg, expected=False ) - assert result is not True, ( - "Testcase : Failed \n " - "Aggregated route is still present \n Error: {}".format( - tc_name, result - ) + assert ( + result is not True + ), "Testcase {} : Failed \n Aggregated route is still present \n Error: {}".format( + tc_name, result ) else: result = verify_rib(tgen, addr_type, "r1", input_static_agg) - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) result = verify_rib(tgen, addr_type, "r3", input_static_agg) - assert result is True, "Testcase : Failed \n Error: {}".format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) diff --git a/tests/topotests/bgp_route_map/test_route_map_topo2.py b/tests/topotests/bgp_route_map/test_route_map_topo2.py index 54b3340d68..d4b145e817 100644 --- a/tests/topotests/bgp_route_map/test_route_map_topo2.py +++ b/tests/topotests/bgp_route_map/test_route_map_topo2.py @@ -74,12 +74,10 @@ TC_59: TC_60 Create route map to deny outbound prefixes with filter match tag, and set criteria -""" ################################# # TOPOLOGY ################################# -""" +-------+ +--------- | R2 | @@ -1049,8 +1047,11 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): result = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n" - "routes are not present \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \nroutes are not present \n Error: {}".format( + tc_name, result + ) logger.info("Expected behaviour: {}".format(result)) # Verifying RIB routes @@ -1060,9 +1061,11 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): result = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n" - "Expected behaviour: routes are not present \n " - "Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \nExpected behaviour: routes are not present \n Error: {}".format( + tc_name, result + ) write_test_footer(tc_name) @@ -1315,8 +1318,11 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): result = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n" - "routes are not present \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \nroutes are not present \n Error: {}".format( + tc_name, result + ) logger.info("Expected behaviour: {}".format(result)) # Verifying RIB routes @@ -1326,8 +1332,11 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): result = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n" - "routes are not present \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \nroutes are not present \n Error: {}".format( + tc_name, result + ) logger.info("Expected behaviour: {}".format(result)) write_test_footer(tc_name) @@ -2155,8 +2164,11 @@ def test_add_remove_rmap_to_specific_neighbor_p0(): result = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n Error" - "Routes are still present: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \n Error Routes are still present: {}".format( + tc_name, result + ) logger.info("Expected behaviour: {}".format(result)) # Remove applied rmap from neighbor @@ -2566,8 +2578,11 @@ def test_rmap_without_match_and_set_clause_p0(): result = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n" - "routes are not present \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \nroutes are not present \n Error: {}".format( + tc_name, result + ) logger.info("Expected behaviour: {}".format(result)) write_test_footer(tc_name) @@ -2811,8 +2826,11 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): input_dict_3_addr_type[addr_type], expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Attributes are not set \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \nAttributes are not set \n Error: {}".format( + tc_name, result + ) logger.info("Expected behaviour: {}".format(result)) # Verifying RIB routes @@ -2842,8 +2860,11 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): input_dict_3_addr_type[addr_type], expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Attributes are not set \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \nAttributes are not set \n Error: {}".format( + tc_name, result + ) logger.info("Expected behaviour: {}".format(result)) write_test_footer(tc_name) @@ -3648,8 +3669,11 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0(): result = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n" - "routes are not present \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \nroutes are not present \n Error: {}".format( + tc_name, result + ) logger.info("Expected behaviour: {}".format(result)) # Verifying RIB routes @@ -3659,8 +3683,11 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0(): result = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n" - "routes are not present \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \nroutes are not present \n Error: {}".format( + tc_name, result + ) logger.info("Expected behaviour: {}".format(result)) write_test_footer(tc_name) @@ -3961,8 +3988,11 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0(): result = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n" - "routes are denied \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \nroutes are denied \n Error: {}".format( + tc_name, result + ) logger.info("Expected behaviour: {}".format(result)) write_test_footer(tc_name) diff --git a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py index 55b4f1581f..63e724cc5c 100644 --- a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py +++ b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py @@ -223,7 +223,6 @@ def disable_route_map_to_prefer_global_next_hop(tgen, topo): """ - tc_name = request.node.name logger.info("Remove prefer-global rmap applied on neighbors") input_dict = { "r1": { @@ -487,7 +486,7 @@ def disable_route_map_to_prefer_global_next_hop(tgen, topo): } result = create_router_bgp(tgen, topo, input_dict) - assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase :Failed \n Error: {}".format(result) return True diff --git a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py index 18f048129c..1241a37cf7 100644 --- a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py +++ b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py @@ -915,7 +915,7 @@ def test_modify_route_map_match_set_clauses_p1(request): rmap_name="rmap_IMP_{}".format(addr_type), input_dict=input_rmap, ) - assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) step("Change community-list to match a different value then " "100:100.") diff --git a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py index 86253acc4d..d72b28e84c 100644 --- a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py +++ b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py @@ -251,9 +251,7 @@ def prerequisite_config_for_test_suite(tgen): } result = configure_vxlan(tgen, vxlan_input) - assert result is True, "Testcase {} :Failed \n Error: {}".format( - tc_name, result - ) + assert result is True, "Testcase :Failed \n Error: {}".format(result) step("Configure bridge interface") brctl_input = { @@ -269,9 +267,7 @@ def prerequisite_config_for_test_suite(tgen): } } result = configure_brctl(tgen, topo, brctl_input) - assert result is True, "Testcase {} :Failed \n Error: {}".format( - tc_name, result - ) + assert result is True, "Testcase :Failed \n Error: {}".format(result) step("Configure default routes") add_default_routes(tgen) @@ -340,7 +336,7 @@ def add_default_routes(tgen): } result = create_static_routes(tgen, default_routes) - assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase :Failed \n Error: {}".format(result) def test_verify_overlay_index_p1(request): @@ -865,8 +861,9 @@ def test_RT_verification_auto_p0(request): } result = verify_rib(tgen, addr_type, "d2", input_routes, expected=False) - assert result is not True, "Testcase {} :Failed \n " - "Routes are still present: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} :Failed \n Routes are still present: {}".format(tc_name, result) logger.info("Expected Behavior: {}".format(result)) step( @@ -1000,8 +997,11 @@ def test_RT_verification_auto_p0(request): result = verify_attributes_for_evpn_routes( tgen, topo, "d2", input_routes_1, rt="auto", rt_peer="e1", expected=False ) - assert result is not True, "Testcase {} :Failed \n " - "Malfaromed Auto-RT value accepted: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} :Failed \n Malfaromed Auto-RT value accepted: {}".format( + tc_name, result + ) logger.info("Expected Behavior: {}".format(result)) step("Configure VNI number more than boundary limit (16777215)") @@ -1032,8 +1032,11 @@ def test_RT_verification_auto_p0(request): result = verify_attributes_for_evpn_routes( tgen, topo, "d2", input_routes_1, rt="auto", rt_peer="e1", expected=False ) - assert result is not True, "Testcase {} :Failed \n " - "Malfaromed Auto-RT value accepted: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} :Failed \n Malfaromed Auto-RT value accepted: {}".format( + tc_name, result + ) logger.info("Expected Behavior: {}".format(result)) step("Un-configure VNI number more than boundary limit (16777215)") diff --git a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py index 4f2aef17c0..fda39be91d 100644 --- a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py +++ b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py @@ -254,9 +254,7 @@ def prerequisite_config_for_test_suite(tgen): } result = configure_vxlan(tgen, vxlan_input) - assert result is True, "Testcase {} on {} :Failed \n Error: {}".format( - tc_name, dut, result - ) + assert result is True, "Testcase :Failed \n Error: {}".format(result) step("Configure bridge interface") brctl_input = { @@ -272,9 +270,7 @@ def prerequisite_config_for_test_suite(tgen): } } result = configure_brctl(tgen, topo, brctl_input) - assert result is True, "Testcase {} on {} :Failed \n Error: {}".format( - tc_name, dut, result - ) + assert result is True, "Testcase :Failed \n Error: {}".format(result) step("Configure default routes") add_default_routes(tgen) @@ -343,7 +339,7 @@ def add_default_routes(tgen): } result = create_static_routes(tgen, default_routes) - assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) + assert result is True, "Testcase :Failed \n Error: {}".format(result) def test_RD_verification_manual_and_auto_p0(request): @@ -1348,15 +1344,17 @@ def test_evpn_routes_from_VNFs_p1(request): for addr_type in ADDR_TYPES: input_routes = {key: topo["routers"][key] for key in ["r1"]} result = verify_rib(tgen, addr_type, "d2", input_routes, expected=False) - assert result is not True, "Testcase {} :Failed \n " - "Routes are still present: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase :Failed \n Routes are still present: {}".format(result) logger.info("Expected Behavior: {}".format(result)) for addr_type in ADDR_TYPES: input_routes = {key: topo["routers"][key] for key in ["r1"]} result = verify_rib(tgen, addr_type, "r3", input_routes, expected=False) - assert result is not True, "Testcase {} :Failed \n " - "Routes are still present: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} :Failed \n Routes are still present: {}".format(tc_name, result) logger.info("Expected Behavior: {}".format(result)) step("Re-advertise IP prefixes from VFN(R1).") @@ -1431,13 +1429,15 @@ def test_evpn_routes_from_VNFs_p1(request): } result = verify_rib(tgen, addr_type, "d2", input_routes, expected=False) - assert result is not True, "Testcase {} :Failed \n " - "Routes are still present: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} :Failed \n Routes are still present: {}".format(tc_name, result) logger.info("Expected Behavior: {}".format(result)) result = verify_rib(tgen, addr_type, "r4", input_routes, expected=False) - assert result is not True, "Testcase {} :Failed \n " - "Routes are still present: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} :Failed \n Routes are still present: {}".format(tc_name, result) logger.info("Expected Behavior: {}".format(result)) step("Add vrf BLUE on router Edge-1 again.") @@ -1532,13 +1532,15 @@ def test_evpn_routes_from_VNFs_p1(request): } result = verify_rib(tgen, addr_type, "d2", input_routes, expected=False) - assert result is not True, "Testcase {} :Failed \n " - "Routes are still present: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} :Failed \n Routes are still present: {}".format(tc_name, result) logger.info("Expected Behavior: {}".format(result)) result = verify_rib(tgen, addr_type, "r4", input_routes, expected=False) - assert result is not True, "Testcase {} :Failed \n " - "Routes are still present: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} :Failed \n Routes are still present: {}".format(tc_name, result) logger.info("Expected Behavior: {}".format(result)) step("Advertise IPv6 address-family in EVPN advertisements " "for VRF GREEN.") @@ -1990,7 +1992,7 @@ def test_bgp_attributes_for_evpn_address_family_p1(request, attribute): input_dict_1 = { "e1": { "route_maps": { - "rmap_d1".format(addr_type): [ + "rmap_d1": [ { "action": "permit", "set": { @@ -2001,7 +2003,7 @@ def test_bgp_attributes_for_evpn_address_family_p1(request, attribute): }, } ], - "rmap_d2".format(addr_type): [ + "rmap_d2": [ { "action": "permit", "set": { @@ -2016,10 +2018,10 @@ def test_bgp_attributes_for_evpn_address_family_p1(request, attribute): input_dict_1 = { "e1": { "route_maps": { - "rmap_d1".format(addr_type): [ + "rmap_d1": [ {"action": "permit", "set": {attribute: 120}} ], - "rmap_d2".format(addr_type): [ + "rmap_d2": [ {"action": "permit", "set": {attribute: 150}} ], } diff --git a/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py b/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py index a253b11c07..5555b1dca0 100755 --- a/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py +++ b/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py @@ -170,7 +170,7 @@ def setup_module(mod): router_list = tgen.routers() # For all registered routers, load the zebra configuration file - for rname, router in router_list.iteritems(): + for rname, router in router_list.items(): router.load_config( TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) ) diff --git a/tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py b/tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py index 325638a478..e2cb080eb7 100755 --- a/tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py +++ b/tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py @@ -172,7 +172,7 @@ def setup_module(mod): router_list = tgen.routers() # For all registered routers, load the zebra configuration file - for rname, router in router_list.iteritems(): + for rname, router in router_list.items(): router.load_config( TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) ) diff --git a/tests/topotests/isis_snmp/test_isis_snmp.py b/tests/topotests/isis_snmp/test_isis_snmp.py index c6fc698005..6ca5928fd9 100755 --- a/tests/topotests/isis_snmp/test_isis_snmp.py +++ b/tests/topotests/isis_snmp/test_isis_snmp.py @@ -142,7 +142,7 @@ def setup_module(mod): router_list = tgen.routers() # For all registered routers, load the zebra configuration file - for rname, router in router_list.iteritems(): + for rname, router in router_list.items(): router.load_config( TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) ) diff --git a/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py b/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py index 06d15afe6c..260457b672 100755 --- a/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py +++ b/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py @@ -167,7 +167,7 @@ def setup_module(mod): router_list = tgen.routers() # For all registered routers, load the zebra configuration file - for rname, router in router_list.iteritems(): + for rname, router in router_list.items(): router.load_config( TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) ) diff --git a/tests/topotests/isis_topo1/test_isis_topo1.py b/tests/topotests/isis_topo1/test_isis_topo1.py index 3927222553..29021c5623 100644 --- a/tests/topotests/isis_topo1/test_isis_topo1.py +++ b/tests/topotests/isis_topo1/test_isis_topo1.py @@ -26,7 +26,6 @@ test_isis_topo1.py: Test ISIS topology. """ -import collections import functools import json import os @@ -263,7 +262,7 @@ def dict_merge(dct, merge_dct): if ( k in dct and isinstance(dct[k], dict) - and isinstance(merge_dct[k], collections.Mapping) + and topotest.is_mapping(merge_dct[k]) ): dict_merge(dct[k], merge_dct[k]) else: diff --git a/tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py b/tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py index 67c60c729f..9c15ee3423 100644 --- a/tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py +++ b/tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py @@ -24,7 +24,6 @@ test_isis_topo1_vrf.py: Test ISIS vrf topology. """ -import collections import functools import json import os @@ -291,7 +290,7 @@ def dict_merge(dct, merge_dct): if ( k in dct and isinstance(dct[k], dict) - and isinstance(merge_dct[k], collections.Mapping) + and topotest.is_mapping(merge_dct[k]) ): dict_merge(dct[k], merge_dct[k]) else: diff --git a/tests/topotests/ldp_topo1/test_ldp_topo1.py b/tests/topotests/ldp_topo1/test_ldp_topo1.py index c0f869f826..62b763ce70 100644 --- a/tests/topotests/ldp_topo1/test_ldp_topo1.py +++ b/tests/topotests/ldp_topo1/test_ldp_topo1.py @@ -337,7 +337,7 @@ def test_mpls_ldp_neighbor_establish(): else: # Bail out with error if a router fails to converge fatal_error = "MPLS LDP neighbors did not establish" - assert False, "MPLS LDP neighbors did not establish" % ospfStatus + assert False, "MPLS LDP neighbors did not establish" print("MPLS LDP neighbors established.") diff --git a/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py b/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py index 60a883b285..5cd5cd1553 100644 --- a/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py +++ b/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py @@ -687,8 +687,9 @@ def test_BSR_CRP_with_blackhole_address_p1(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) step("Sending BSR after Configure black hole address for BSR and candidate RP") step("Send BSR packet from b1 to FHR") @@ -711,8 +712,9 @@ def test_BSR_CRP_with_blackhole_address_p1(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) result = verify_state_incremented(state_before, state_after) assert result is not True, "Testcase{} : Failed Error: {}".format(tc_name, result) @@ -1329,8 +1331,7 @@ def test_bsmp_stress_add_del_restart_p2(request): assert ( rp_add1 == rp2[group] ), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format( - tc_name, - rp_add1, + tc_name, rp_add1, rp2[group] ) # Verify if that rp is installed diff --git a/tests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py b/tests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py index 487ec924e9..d808a60c05 100755 --- a/tests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py +++ b/tests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py @@ -348,8 +348,9 @@ def test_multicast_data_traffic_static_RP_send_join_then_traffic_p0(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase {} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase {} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, state_before + ) result = iperfSendIGMPJoin(tgen, "i1", ["{}%{}".format(IGMP_JOIN, intf_i1_l1)], join_interval=1) assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result) @@ -419,8 +420,9 @@ def test_multicast_data_traffic_static_RP_send_join_then_traffic_p0(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase {} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase {} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) step( "l1 sent PIM (*,G) join to r2 verify using" @@ -501,8 +503,9 @@ def test_multicast_data_traffic_static_RP_send_traffic_then_join_p0(request): state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_before, dict - ), "Testcase {} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase {} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) result = iperfSendIGMPJoin(tgen, "i1", IGMP_JOIN, join_interval=1) assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result) @@ -544,8 +547,9 @@ def test_multicast_data_traffic_static_RP_send_traffic_then_join_p0(request): state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( state_after, dict - ), "Testcase {} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase {} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) step( "l1 sent PIM (*,G) join to r2 verify using" @@ -951,8 +955,11 @@ def test_verify_mroute_when_same_receiver_joining_5_diff_sources_p0(request): data["oil"], expected=False, ) - assert result is not True, "Testcase {} : Failed \n mroutes are" - " still present \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \n mroutes are still present \n Error: {}".format( + tc_name, result + ) logger.info("Expected Behavior: {}".format(result)) step( @@ -1178,8 +1185,11 @@ def test_verify_mroute_when_frr_is_transit_router_p2(request): result = verify_ip_mroutes( tgen, "c1", "*", IGMP_JOIN, "c1-c2-eth1", "c1-l1-eth0", expected=False ) - assert result is not True, "Testcase {} : Failed \n mroutes are" - " still present \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \n mroutes are still present \n Error: {}".format( + tc_name, result + ) logger.info("Expected Behavior: {}".format(result)) write_test_footer(tc_name) @@ -1291,8 +1301,11 @@ def test_verify_mroute_when_RP_unreachable_p1(request): result = verify_ip_mroutes( tgen, "f1", "*", IGMP_JOIN, "f1-r2-eth3", "f1-i8-eth2", expected=False ) - assert result is not True, "Testcase {} : Failed \n mroutes are" - " still present \n Error: {}".format(tc_name, result) + assert ( + result is not True + ), "Testcase {} : Failed \n mroutes are still present \n Error: {}".format( + tc_name, result + ) logger.info("Expected Behavior: {}".format(result)) step("IGMP groups are present verify using 'show ip igmp group'") diff --git a/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py b/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py index 0b9c216c66..d2bddc43b7 100755 --- a/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py +++ b/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py @@ -1046,8 +1046,9 @@ def test_PIM_hello_tx_rx_p1(request): c1_state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( c1_state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) step("Flap PIM nbr while doing interface c1-l1 interface shut from f1 side") shutdown_bringup_interface(tgen, "c1", intf_c1_l1, False) @@ -1062,8 +1063,9 @@ def test_PIM_hello_tx_rx_p1(request): c1_state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( c1_state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) step("verify stats not increamented on c1") result = verify_state_incremented(c1_state_before, c1_state_after) @@ -1081,8 +1083,9 @@ def test_PIM_hello_tx_rx_p1(request): l1_state_before = verify_pim_interface_traffic(tgen, l1_state_dict) assert isinstance( l1_state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) step("Flap PIM nbr while doing interface r2-c1 shut from r2 side") shutdown_bringup_interface(tgen, "l1", intf_l1_c1, False) @@ -1097,8 +1100,9 @@ def test_PIM_hello_tx_rx_p1(request): l1_state_after = verify_pim_interface_traffic(tgen, l1_state_dict) assert isinstance( l1_state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) step("verify stats not increamented on l1") result = verify_state_incremented(l1_state_before, l1_state_after) @@ -1122,8 +1126,9 @@ def test_PIM_hello_tx_rx_p1(request): c1_state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( c1_state_before, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) step("Flap c1-r2 pim nbr while changing ip address from c1 side") c1_l1_ip_subnet = topo["routers"]["c1"]["links"]["l1"]["ipv4"] @@ -1145,8 +1150,9 @@ def test_PIM_hello_tx_rx_p1(request): c1_state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( c1_state_after, dict - ), "Testcase{} : Failed \n state_before is not dictionary \n " - "Error: {}".format(tc_name, result) + ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format( + tc_name, result + ) step("verify stats not increamented on c1") result = verify_state_incremented(c1_state_before, c1_state_after) diff --git a/tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py b/tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py index ba8ea0be63..b57c5b16da 100755 --- a/tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py +++ b/tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py @@ -759,7 +759,7 @@ def test_not_reachable_static_RP_p0(request): assert isinstance( state_before, dict ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( - tc_name, result + tc_name, state_before ) step("Enable IGMP on r1 interface and send IGMP " "join (225.1.1.1) to r1") @@ -1088,7 +1088,7 @@ def test_reachable_static_RP_after_join_p0(request): assert isinstance( state_before, dict ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( - tc_name, result + tc_name, state_before ) step("r1: Make RP un-reachable") @@ -1277,7 +1277,7 @@ def test_send_join_on_higher_preffered_rp_p1(request): assert isinstance( state_before, dict ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format( - tc_name, result + tc_name, state_before ) step("r0 : Send IGMP join for 225.1.1.1") diff --git a/tests/topotests/nhrp_topo/test_nhrp_topo.py b/tests/topotests/nhrp_topo/test_nhrp_topo.py index 081c63a185..6d3cc3a552 100644 --- a/tests/topotests/nhrp_topo/test_nhrp_topo.py +++ b/tests/topotests/nhrp_topo/test_nhrp_topo.py @@ -105,7 +105,7 @@ def setup_module(mod): router_list = tgen.routers() _populate_iface() - for rname, router in router_list.iteritems(): + for rname, router in router_list.items(): router.load_config( TopoRouter.RD_ZEBRA, os.path.join(CWD, '{}/zebra.conf'.format(rname)), @@ -142,7 +142,7 @@ def test_protocols_convergence(): logger.info("Checking NHRP cache and IPv4 routes for convergence") router_list = tgen.routers() - for rname, router in router_list.iteritems(): + for rname, router in router_list.items(): if rname == 'r3': continue @@ -163,7 +163,7 @@ def test_protocols_convergence(): assertmsg = '"{}" JSON output mismatches'.format(router.name) assert result is None, assertmsg - for rname, router in router_list.iteritems(): + for rname, router in router_list.items(): if rname == 'r3': continue @@ -184,7 +184,7 @@ def test_protocols_convergence(): assertmsg = '"{}" JSON output mismatches'.format(router.name) assert result is None, assertmsg - for rname, router in router_list.iteritems(): + for rname, router in router_list.items(): if rname == 'r3': continue logger.info('Dump neighbor information on {}-gre0'.format(rname)) diff --git a/tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py b/tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py index fc1a472a17..28e89dfa52 100755 --- a/tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py +++ b/tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py @@ -287,7 +287,7 @@ def test_ospfv3_routingTable(): # For debugging, uncomment the next line # tgen.mininet_cli() # Verify OSPFv3 Routing Table - for router, rnode in tgen.routers().iteritems(): + for router, rnode in tgen.routers().items(): logger.info('Waiting for router "%s" convergence', router) # Load expected results from the command @@ -418,7 +418,7 @@ def test_ospfv3_routingTable_write_multiplier(): r1.vtysh_cmd("clear ipv6 ospf interface r1-sw5") # Verify OSPFv3 Routing Table - for router, rnode in tgen.routers().iteritems(): + for router, rnode in tgen.routers().items(): logger.info('Waiting for router "%s" convergence', router) # Load expected results from the command diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py b/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py index 5533136457..0c2619d2f6 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py @@ -229,7 +229,7 @@ def test_ospf_p2mp_tc1_p0(request): topo_modify_change_ip = deepcopy(topo) intf_ip = topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv4"] topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv4"] = str( - IPv4Address(unicode(intf_ip.split("/")[0])) + 3 + IPv4Address(frr_unicode(intf_ip.split("/")[0])) + 3 ) + "/{}".format(intf_ip.split("/")[1]) build_config_from_json(tgen, topo_modify_change_ip, save_bkup=False) @@ -280,7 +280,7 @@ def test_ospf_p2mp_tc1_p0(request): topo_modify_change_ip = deepcopy(topo) intf_ip = topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv4"] topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv4"] = str( - IPv4Address(unicode(intf_ip.split("/")[0])) + 3 + IPv4Address(frr_unicode(intf_ip.split("/")[0])) + 3 ) + "/{}".format(int(intf_ip.split("/")[1]) + 1) build_config_from_json(tgen, topo_modify_change_ip, save_bkup=False) diff --git a/tests/topotests/pim_acl/test_pim_acl.py b/tests/topotests/pim_acl/test_pim_acl.py index 0f172d3d9d..4414713d8e 100755 --- a/tests/topotests/pim_acl/test_pim_acl.py +++ b/tests/topotests/pim_acl/test_pim_acl.py @@ -69,7 +69,8 @@ test_pim_acl.py: Test PIM with RP selection using ACLs # shutdown topology # - +# XXX clean up in later commit to avoid conflict on rebase +# pylint: disable=C0413 TOPOLOGY = """ +----------+ | Host H2 | diff --git a/tests/topotests/pim_igmp_vrf/test_pim_vrf.py b/tests/topotests/pim_igmp_vrf/test_pim_vrf.py index cb207cb810..a0f9e87b2a 100755 --- a/tests/topotests/pim_igmp_vrf/test_pim_vrf.py +++ b/tests/topotests/pim_igmp_vrf/test_pim_vrf.py @@ -26,6 +26,9 @@ test_pim_vrf.py: Test PIM with VRFs. """ +# XXX clean up in later commit to avoid conflict on rebase +# pylint: disable=C0413 + # Tests PIM with VRF # # R1 is split into 2 VRF: Blue and Red, the others are normal -- 2.39.5