Skip to content

Commit

Permalink
[Python3 migration]Fix test failure in test_sub_port_l2_forwarding.py
Browse files Browse the repository at this point in the history
Summary:
Fixes sonic-net#7884 [test_sub_port_l2_forwarding] [test issue] TypeError: a bytes-like object is required, not 'str'

What is the motivation for this PR?
test sub_port_interfaces/test_sub_port_l2_forwarding.py fail over python3 issue:
TypeError: a bytes-like object is required, not 'str'

How did you do it?
In Python3, a string cannot work with bytes
Use str to convert bytes to string

How did you verify/test it?
The change can work both in Python2 and Python3.
  • Loading branch information
wsycqyz authored and AharonMalkin committed Jan 25, 2024
1 parent d400e02 commit 882a7e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/sub_port_interfaces/test_sub_port_l2_forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def check_no_cpu_packets(duthost, port, packet_fingerprint):
def verify_no_packet_received(ptfadapter, ports, packet_fingerprint):
for port in ports:
for packet, _ in ptfadapter.dataplane.packet_queues[(0, port)]:
if packet_fingerprint in packet:
if packet_fingerprint in str(packet):
logging.error("Received packet with fingerprint '%s' on port %s: %s\n", port, packet_fingerprint,
packet)
str(packet))
pytest.fail("Received packet on port %s" % port)

duthost = duthosts[rand_one_dut_hostname]
Expand Down

0 comments on commit 882a7e5

Please sign in to comment.