Skip to content

Commit

Permalink
Fix lambda TypeError in ptfhost_utils (#5845)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ZhaohuiS authored Jun 22, 2022
1 parent 9f7af40 commit 676a093
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tests/common/fixtures/ptfhost_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/")

Expand Down

0 comments on commit 676a093

Please sign in to comment.