Skip to content

Commit 2b4b64f

Browse files
author
Filip Jagodzinski
committed
Tests: USB: Fix Python 3 compatibility
Use integer division explicitly in basic test. Convert bytes to str for Python 3 in serial test.
1 parent c323af8 commit 2b4b64f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

TESTS/host_tests/pyusb_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ def ep_test_abort(dev, log, verbose=False):
13761376
payload_size = (NUM_PACKETS_UNTIL_ABORT + NUM_PACKETS_AFTER_ABORT) * ep_out.wMaxPacketSize
13771377
num_bytes_written = 0
13781378
while num_bytes_written < payload_size:
1379-
payload_out = array.array('B', (num_bytes_written/ep_out.wMaxPacketSize
1379+
payload_out = array.array('B', (num_bytes_written//ep_out.wMaxPacketSize
13801380
for _ in range(ep_out.wMaxPacketSize)))
13811381
try:
13821382
num_bytes_written += ep_out.write(payload_out)

TESTS/host_tests/usb_device_serial.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import sys
2525
import serial
2626
import serial.tools.list_ports as stlp
27+
import six
2728
import mbed_host_tests
2829

2930

@@ -268,7 +269,7 @@ def change_line_coding(self):
268269
mbed_serial.reset_output_buffer()
269270
mbed_serial.dtr = True
270271
try:
271-
payload = mbed_serial.read(LINE_CODING_STRLEN)
272+
payload = six.ensure_str(mbed_serial.read(LINE_CODING_STRLEN))
272273
while len(payload) == LINE_CODING_STRLEN:
273274
baud, bits, parity, stop = (int(i) for i in payload.split(','))
274275
new_line_coding = {
@@ -277,7 +278,7 @@ def change_line_coding(self):
277278
'parity': self._PARITIES[parity],
278279
'stopbits': self._STOPBITS[stop]}
279280
mbed_serial.apply_settings(new_line_coding)
280-
payload = mbed_serial.read(LINE_CODING_STRLEN)
281+
payload = six.ensure_str(mbed_serial.read(LINE_CODING_STRLEN))
281282
except serial.SerialException as exc:
282283
self.log('TEST ERROR: {}'.format(exc))
283284
self.notify_complete(False)

0 commit comments

Comments
 (0)