Skip to content

Commit c440920

Browse files
lizhijianrdmssonicbld
authored andcommitted
[tests/crm] Fix python3 syntax error in test_acl_entry (sonic-net#9208)
What is the motivation for this PR? Fix a python3 syntax error in testcase crm/test_crm.py::test_acl_entry. In python2 dict.keys() returns a list object, but in python3 it returns a dict_keys object which is not sortable. How did you do it? Use sorted() function instead of dict.keys().sort(). sorted() function can put the keys of a dict in a list in sorted order, and it has same action in Python2 and Python3. How did you verify/test it? Verified by running testcase on Marvell testbed. Signed-off-by: Zhijian Li <zhijianli@microsoft.com>
1 parent a08b96e commit c440920

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

tests/crm/test_crm.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,8 +910,7 @@ def test_acl_entry(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_fro
910910
if duthost.facts["asic_type"] == "marvell":
911911
# Remove DATA ACL Table and add it again with ports in same port group
912912
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)
913-
tmp_ports = mg_facts["minigraph_ports"].keys()
914-
tmp_ports.sort(key=lambda x: int(x[8:]))
913+
tmp_ports = sorted(mg_facts["minigraph_ports"], key=lambda x: int(x[8:]))
915914
for i in range(4):
916915
if i == 0:
917916
ports = ",".join(tmp_ports[17:19])

0 commit comments

Comments
 (0)