From 676a093e98bc41d7245793b5ecc0b947b6c7296c Mon Sep 17 00:00:00 2001 From: Zhaohui Sun <94606222+ZhaohuiS@users.noreply.github.com> Date: Wed, 22 Jun 2022 09:15:03 +0800 Subject: [PATCH] Fix lambda TypeError in ptfhost_utils (#5845) What is the motivation for this PR? Fix the issue reported in #4867, failures: TypeError: () takes exactly 2 arguments (1 given) The fix in #5605 still uses lambda which is not easy to read and may have compatibility issue. How did you do it? Use for loop and concentrate string together and append them to a list. How did you verify/test it? run tests/test_qos_sai.py Signed-off-by: Zhaohui Sun --- tests/common/fixtures/ptfhost_utils.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/common/fixtures/ptfhost_utils.py b/tests/common/fixtures/ptfhost_utils.py index 0f737d6f9e6..27346ac70d7 100644 --- a/tests/common/fixtures/ptfhost_utils.py +++ b/tests/common/fixtures/ptfhost_utils.py @@ -180,12 +180,10 @@ def ptf_portmap_file(duthosts, rand_one_dut_hostname, ptfhost): portMapFile = "/tmp/default_interface_to_front_map.ini" with open(portMapFile, 'w') as file: file.write("# ptf host interface @ switch front port name\n") - file.writelines( - map( - lambda index, port: "{0}@{1}\n".format(index, port), - enumerate(portList) - ) - ) + ptf_port_map = [] + for i in range(len(portList)): + ptf_port_map.append("{}@{}\n".format(i, portList[i])) + file.writelines(ptf_port_map) ptfhost.copy(src=portMapFile, dest="/root/")