Skip to content

Fix USB tests working with python 3 #11520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions TESTS/host_tests/pyusb_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def get_descriptor_test(dev, vendor_id, product_id, log):
# device descriptor
try:
ret = get_descriptor(dev, (DESC_TYPE_DEVICE << 8) | (0 << 0), 0, DEVICE_DESC_SIZE)
dev_desc = dict(zip(device_descriptor_keys, device_descriptor_parser.unpack(ret)))
dev_desc = dict(list(zip(device_descriptor_keys, device_descriptor_parser.unpack(ret))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to make a list here. dict() can handle generators just fine.

raise_if_different(DEVICE_DESC_SIZE, dev_desc['bLength'], lineno(), text='Wrong device descriptor size !!!')
raise_if_different(vendor_id, dev_desc['idVendor'], lineno(), text='Wrong vendor id !!!')
raise_if_different(product_id, dev_desc['idProduct'], lineno(), text='Wrong product id !!!')
Expand All @@ -657,7 +657,7 @@ def get_descriptor_test(dev, vendor_id, product_id, log):
# configuration descriptor
try:
ret = get_descriptor(dev, (DESC_TYPE_CONFIG << 8) | (0 << 0), 0, CONFIGURATION_DESC_SIZE)
conf_desc = dict(zip(configuration_descriptor_keys, configuration_descriptor_parser.unpack(ret)))
conf_desc = dict(list(zip(configuration_descriptor_keys, configuration_descriptor_parser.unpack(ret))))
raise_if_different(CONFIGURATION_DESC_SIZE, conf_desc['bLength'], lineno(), text='Wrong configuration descriptor size !!!')
except usb.core.USBError:
raise_unconditionally(lineno(), "Requesting configuration descriptor failed")
Expand Down
2 changes: 1 addition & 1 deletion TESTS/host_tests/usb_device_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def send_data_sequence(self, chunk_size=1):
return
mbed_serial.reset_output_buffer()
mbed_serial.dtr = True
for byteval in itertools.chain(reversed(range(0x100)), range(0x100)):
for byteval in itertools.chain(reversed(list(range(0x100))), list(range(0x100))):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add list() here.

try:
payload = bytearray(chunk_size * (byteval,))
mbed_serial.write(payload)
Expand Down