Skip to content

Commit 42616f0

Browse files
xwjiang-msgshemesh2
authored andcommitted
[pre-commit] Use correct comment format # noqa: not # noqa in tests/b* (sonic-net#17759)
What is the motivation for this PR? In pre-commit, we were using # noqa to ignore failures/errors/warnings in our code, but once we use # noqa, it will ignore all pre-commit errors in this line, the correct solution is using # noqa: so only specific failures/errors/warnings would be ignored. How did you do it? Replace # noqa with # noqa: in tests/b* Signed-off-by: Guy Shemesh <[email protected]>
1 parent 77738c2 commit 42616f0

9 files changed

Lines changed: 40 additions & 38 deletions

tests/bfd/test_bfd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import logging
66

7-
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor_m # noqa F401
7+
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor_m # noqa:F401
88
from tests.common.snappi_tests.common_helpers import get_egress_queue_count
99

1010
pytestmark = [
@@ -471,7 +471,7 @@ def test_bfd_scale(request, rand_selected_dut, ptfhost, tbinfo, ipv6):
471471

472472
@pytest.mark.parametrize('ipv6', [False, True], ids=['ipv4', 'ipv6'])
473473
def test_bfd_multihop(request, rand_selected_dut, ptfhost, tbinfo,
474-
toggle_all_simulator_ports_to_rand_selected_tor_m, ipv6): # noqa F811
474+
toggle_all_simulator_ports_to_rand_selected_tor_m, ipv6): # noqa:F811
475475
duthost = rand_selected_dut
476476

477477
bfd_session_cnt = int(request.config.getoption('--num_sessions'))

tests/bgp/test_bgp_allow_list.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from bgp_helpers import apply_allow_list, remove_allow_list, check_routes_on_from_neighbor, get_default_action
1111
from bgp_helpers import check_routes_on_neighbors_empty_allow_list, checkout_bgp_mon_routes, check_routes_on_neighbors
1212
# Fixtures
13-
from bgp_helpers import bgp_allow_list_setup, prepare_eos_routes # noqa F401
13+
from bgp_helpers import bgp_allow_list_setup, prepare_eos_routes # noqa:F401
1414

1515
pytestmark = [
1616
pytest.mark.topology('t1', 'm1', 'm2', 'm3'),
@@ -37,7 +37,7 @@
3737

3838

3939
@pytest.fixture
40-
def load_remove_allow_list(duthosts, bgp_allow_list_setup, rand_one_dut_hostname, request): # noqa F811
40+
def load_remove_allow_list(duthosts, bgp_allow_list_setup, rand_one_dut_hostname, request): # noqa:F811
4141
allowed_list_prefixes = ALLOW_LIST['BGP_ALLOWED_PREFIXES']
4242
for _, value in list(allowed_list_prefixes.items()):
4343
value['default_action'] = request.param
@@ -61,7 +61,7 @@ def check_routes_on_dut(duthost, namespace):
6161
pytest_assert(dut_route, 'Route {} is not found on DUT'.format(prefix))
6262

6363

64-
def test_default_allow_list_preconfig(duthosts, rand_one_dut_hostname, bgp_allow_list_setup, nbrhosts, # noqa F811
64+
def test_default_allow_list_preconfig(duthosts, rand_one_dut_hostname, bgp_allow_list_setup, nbrhosts, # noqa:F811
6565
ptfhost, bgpmon_setup_teardown):
6666
"""
6767
Before applying allow list, verify bgp policy by default config
@@ -79,7 +79,7 @@ def test_default_allow_list_preconfig(duthosts, rand_one_dut_hostname, bgp_allow
7979

8080

8181
@pytest.mark.parametrize('load_remove_allow_list', ["permit", "deny"], indirect=['load_remove_allow_list'])
82-
def test_allow_list(duthosts, rand_one_dut_hostname, bgp_allow_list_setup, nbrhosts, # noqa F811
82+
def test_allow_list(duthosts, rand_one_dut_hostname, bgp_allow_list_setup, nbrhosts, # noqa:F811
8383
load_remove_allow_list, ptfhost, bgpmon_setup_teardown):
8484
permit = True if load_remove_allow_list == "permit" else False
8585
duthost = duthosts[rand_one_dut_hostname]
@@ -95,10 +95,10 @@ def test_allow_list(duthosts, rand_one_dut_hostname, bgp_allow_list_setup, nbrho
9595
checkout_bgp_mon_routes(duthost, ptfhost)
9696

9797

98-
def test_default_allow_list_postconfig(duthosts, rand_one_dut_hostname, bgp_allow_list_setup, # noqa F811
98+
def test_default_allow_list_postconfig(duthosts, rand_one_dut_hostname, bgp_allow_list_setup, # noqa:F811
9999
nbrhosts, ptfhost, bgpmon_setup_teardown):
100100
"""
101101
After removing allow list, verify bgp policy
102102
"""
103-
test_default_allow_list_preconfig(duthosts, rand_one_dut_hostname, bgp_allow_list_setup, # noqa F811
103+
test_default_allow_list_preconfig(duthosts, rand_one_dut_hostname, bgp_allow_list_setup, # noqa:F811
104104
nbrhosts, ptfhost, bgpmon_setup_teardown)

tests/bgp/test_bgp_bbr.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def check_tor1(nbrhosts, setup, route):
316316
logging.warning('No route for {} found on {}'.format(route.prefix, tor1))
317317
return False
318318
tor1_route_aspath = tor1_route['vrfs']['default']['bgpRouteEntries'][route.prefix]['bgpRoutePaths'][0]\
319-
['asPathEntry']['asPath'] # noqa E211
319+
['asPathEntry']['asPath'] # noqa:E211
320320
if not tor1_route_aspath == route.aspath:
321321
logging.warning(
322322
'On {} expected aspath: {}, actual aspath: {}'.format(tor1, route.aspath, tor1_route_aspath)
@@ -383,7 +383,7 @@ def check_other_vms(nbrhosts, setup, route, accepted=True, node=None, results=No
383383
vm_route['message'] = 'No route for {} found on {}'.format(route.prefix, node)
384384
else:
385385
tor_route_aspath = vm_route['vrfs']['default']['bgpRouteEntries'][route.prefix]['bgpRoutePaths'][0]\
386-
['asPathEntry']['asPath'] # noqa E211
386+
['asPathEntry']['asPath'] # noqa:E211
387387
# Route path from other VMs: -> DUT(T1) -> TOR1 -> aspath(other T1 -> DUMMY_ASN1)
388388
tor_route_aspath_expected = '{} {} {}'.format(dut_asn, tor1_asn, route.aspath)
389389
if tor_route_aspath != tor_route_aspath_expected:
@@ -466,9 +466,10 @@ def test_bbr_status_consistent_after_reload(duthosts, rand_one_dut_hostname, set
466466
pytest_assert(bbr_status_after_reload == bbr_status, "BGP BBR status is not consistent after config reload")
467467

468468
# Check if BBR is enabled or disabled using the running configuration
469-
bbr_status_running_config = duthost.shell("show runningconfiguration bgp | grep allowas", module_ignore_errors=True)\
470-
['stdout'] # noqa E211
469+
bbr_status_running_config = duthost.shell(
470+
"show runningconfiguration bgp | grep allowas", module_ignore_errors=True)['stdout'] # noqa:E211
471471
if bbr_status == 'enabled':
472472
pytest_assert('allowas-in' in bbr_status_running_config, "BGP BBR is not enabled in running configuration")
473473
else:
474-
pytest_assert('allowas-in' not in bbr_status_running_config, "BGP BBR is not disabled in running configuration")
474+
pytest_assert('allowas-in' not in bbr_status_running_config,
475+
"BGP BBR is not disabled in running configuration")

tests/bgp/test_bgp_dual_asn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
delete_checkpoint,
2222
rollback_or_reload,
2323
)
24-
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor_m # noqa F401
24+
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor_m # noqa:F401
2525
from tests.common.helpers.dut_ports import get_vlan_interface_list, get_vlan_interface_info
2626

2727
pytestmark = [pytest.mark.topology("t0")]
@@ -72,7 +72,7 @@ def lo_intfs(duthost, tbinfo):
7272

7373
@pytest.fixture(autouse=True)
7474
def setup_env(
75-
duthosts, rand_one_dut_hostname, toggle_all_simulator_ports_to_rand_selected_tor_m, # noqa F811
75+
duthosts, rand_one_dut_hostname, toggle_all_simulator_ports_to_rand_selected_tor_m, # noqa:F811
7676
):
7777
"""
7878
Setup/teardown fixture for bgp speaker config

tests/bgp/test_bgp_slb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from tests.common import reboot
44
from tests.common.helpers.bgp import BGPNeighbor
55
from tests.common.dualtor.mux_simulator_control import \
6-
toggle_all_simulator_ports_to_enum_rand_one_per_hwsku_frontend_host_m # noqa F401
6+
toggle_all_simulator_ports_to_enum_rand_one_per_hwsku_frontend_host_m # noqa:F401
77
from tests.common.utilities import wait_until, delete_running_config
88
from tests.common.helpers.assertions import pytest_require
99

@@ -68,7 +68,7 @@ def bgp_slb_neighbor(duthosts, enum_rand_one_per_hwsku_frontend_hostname, setup_
6868
@pytest.mark.disable_loganalyzer
6969
def test_bgp_slb_neighbor_persistence_across_advanced_reboot(
7070
duthosts, enum_rand_one_per_hwsku_frontend_hostname, bgp_slb_neighbor,
71-
toggle_all_simulator_ports_to_enum_rand_one_per_hwsku_frontend_host_m, reboot_type, localhost # noqa F811
71+
toggle_all_simulator_ports_to_enum_rand_one_per_hwsku_frontend_host_m, reboot_type, localhost # noqa:F811
7272
):
7373

7474
def verify_bgp_session(duthost, bgp_neighbor):

tests/bgp/test_bgp_speaker.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
import json
88

99
from tests.common import constants
10-
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa F401
11-
from tests.common.fixtures.ptfhost_utils import set_ptf_port_mapping_mode # noqa F401
12-
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
13-
from tests.common.fixtures.ptfhost_utils import remove_ip_addresses # noqa F401
10+
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa:F401
11+
from tests.common.fixtures.ptfhost_utils import set_ptf_port_mapping_mode # noqa:F401
12+
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa:F401
13+
from tests.common.fixtures.ptfhost_utils import remove_ip_addresses # noqa:F401
1414
from tests.ptf_runner import ptf_runner
1515
from tests.common.utilities import wait_tcp_connection
1616
from tests.common.helpers.assertions import pytest_require
1717
from tests.common.utilities import wait_until
18-
from tests.common.flow_counter.flow_counter_utils import RouteFlowCounterTestContext, is_route_flow_counter_supported # noqa F401
18+
from tests.common.flow_counter.flow_counter_utils import RouteFlowCounterTestContext, \
19+
is_route_flow_counter_supported # noqa:F401
1920
from tests.common.helpers.dut_ports import get_vlan_interface_list, get_vlan_interface_info
2021

2122

@@ -263,7 +264,7 @@ def is_all_neighbors_learned(duthost, speaker_ips):
263264
def bgp_speaker_announce_routes_common(common_setup_teardown, tbinfo, duthost,
264265
ptfhost, ipv4, ipv6, mtu,
265266
family, prefix, nexthop_ips, vlan_mac,
266-
is_route_flow_counter_supported): # noqa F811
267+
is_route_flow_counter_supported): # noqa:F811
267268
"""Setup bgp speaker on T0 topology and verify routes advertised by bgp speaker is received by T0 TOR
268269
269270
"""
@@ -354,7 +355,7 @@ def bgp_speaker_announce_routes_common(common_setup_teardown, tbinfo, duthost,
354355
@pytest.mark.parametrize("ipv4, ipv6, mtu", [pytest.param(True, False, 9114)])
355356
def test_bgp_speaker_announce_routes(common_setup_teardown, tbinfo, duthosts,
356357
rand_one_dut_hostname, ptfhost, ipv4, ipv6, mtu,
357-
vlan_mac, is_route_flow_counter_supported): # noqa F811
358+
vlan_mac, is_route_flow_counter_supported): # noqa:F811
358359
"""Setup bgp speaker on T0 topology and verify routes advertised by bgp speaker is received by T0 TOR
359360
360361
"""
@@ -367,7 +368,7 @@ def test_bgp_speaker_announce_routes(common_setup_teardown, tbinfo, duthosts,
367368
@pytest.mark.parametrize("ipv4, ipv6, mtu", [pytest.param(False, True, 9114)])
368369
def test_bgp_speaker_announce_routes_v6(common_setup_teardown, tbinfo, duthosts,
369370
rand_one_dut_hostname, ptfhost, ipv4, ipv6, mtu,
370-
vlan_mac, is_route_flow_counter_supported): # noqa F811
371+
vlan_mac, is_route_flow_counter_supported): # noqa:F811
371372
"""Setup bgp speaker on T0 topology and verify routes advertised by bgp speaker is received by T0 TOR
372373
373374
"""

tests/bgp/test_bgp_update_timer.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
from tests.common.utilities import wait_until, delete_running_config
2121

2222
from tests.common.helpers.assertions import pytest_assert
23-
from tests.common.dualtor.dual_tor_common import active_active_ports # noqa F401
24-
from tests.common.dualtor.dual_tor_common import active_standby_ports # noqa F401
25-
from tests.common.dualtor.dual_tor_utils import validate_active_active_dualtor_setup # noqa F401
26-
from tests.common.dualtor.mux_simulator_control import mux_server_url # noqa F401
27-
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_enum_rand_one_per_hwsku_frontend_host_m # noqa F401
23+
from tests.common.dualtor.dual_tor_common import active_active_ports # noqa:F401
24+
from tests.common.dualtor.dual_tor_common import active_standby_ports # noqa:F401
25+
from tests.common.dualtor.dual_tor_utils import validate_active_active_dualtor_setup # noqa:F401
26+
from tests.common.dualtor.mux_simulator_control import mux_server_url # noqa:F401
27+
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_enum_rand_one_per_hwsku_frontend_host_m # noqa:F401 E501
2828
from tests.common.helpers.constants import DEFAULT_NAMESPACE
2929

3030

@@ -254,8 +254,8 @@ def test_bgp_update_timer_single_route(
254254
duthosts,
255255
enum_rand_one_per_hwsku_frontend_hostname,
256256
request,
257-
toggle_all_simulator_ports_to_enum_rand_one_per_hwsku_frontend_host_m, # noqa F811
258-
validate_active_active_dualtor_setup, # noqa F811
257+
toggle_all_simulator_ports_to_enum_rand_one_per_hwsku_frontend_host_m, # noqa:F811
258+
validate_active_active_dualtor_setup, # noqa:F811
259259
):
260260
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
261261

@@ -376,8 +376,8 @@ def test_bgp_update_timer_session_down(
376376
duthosts,
377377
enum_rand_one_per_hwsku_frontend_hostname,
378378
request,
379-
toggle_all_simulator_ports_to_enum_rand_one_per_hwsku_frontend_host_m, # noqa F811
380-
validate_active_active_dualtor_setup, # noqa F811
379+
toggle_all_simulator_ports_to_enum_rand_one_per_hwsku_frontend_host_m, # noqa:F811
380+
validate_active_active_dualtor_setup, # noqa:F811
381381
):
382382
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
383383

tests/bgp/test_bgpmon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import ptf.packet as scapy
77
from ptf.mask import Mask
88
import json
9-
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
10-
from tests.common.fixtures.ptfhost_utils import remove_ip_addresses # noqa F401
9+
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa:F401
10+
from tests.common.fixtures.ptfhost_utils import remove_ip_addresses # noqa:F401
1111
from tests.common.helpers.generators import generate_ip_through_default_route
1212
from tests.common.helpers.assertions import pytest_assert
1313
from tests.common.utilities import wait_until

tests/bgp/test_bgpmon_v6.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from jinja2 import Template
66
import json
77
import random
8-
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
9-
from tests.common.fixtures.ptfhost_utils import remove_ip_addresses # noqa F401
8+
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa:F401
9+
from tests.common.fixtures.ptfhost_utils import remove_ip_addresses # noqa:F401
1010
from tests.common.helpers.generators import generate_ip_through_default_route, generate_ip_through_default_v6_route
1111
from tests.common.helpers.assertions import pytest_assert
1212
from tests.common.utilities import wait_until

0 commit comments

Comments
 (0)