Browse Source

Merge pull request #4 from dokthar/fix_strdesc

Fix DeviceDescriptorCollection always adding a language descriptor
main
Kate Temkin 4 years ago
committed by GitHub
parent
commit
414778ad3e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      usb_protocol/emitters/descriptors/standard.py

+ 12
- 1
usb_protocol/emitters/descriptors/standard.py View File

@@ -264,7 +264,7 @@ class DeviceDescriptorCollection:

# If we're not automatically adding a language descriptor, we shouldn't do anything,
# and we'll just ignore this.
if not self._ensure_has_language_descriptor:
if not self._automatic_language_descriptor:
return

# If we don't have a language descriptor, add our default one.
@@ -401,5 +401,16 @@ class EmitterTests(unittest.TestCase):
# Configuration descriptor, with subordinates.
self.assertIn((2, 0, b'\t\x02 \x00\x01\x01\x00\x80\xfa\t\x04\x01\x00\x02\xff\xff\xff\x00\x07\x05\x81\x02@\x00\xff\x07\x05\x01\x02@\x00\xff'), results)


def test_empty_descriptor_collection(self):
collection = DeviceDescriptorCollection(automatic_language_descriptor=False)
results = list(collection)
self.assertEqual(len(results), 0)

def test_automatic_language_descriptor(self):
collection = DeviceDescriptorCollection(automatic_language_descriptor=True)
results = list(collection)
self.assertEqual(len(results), 1)

if __name__ == "__main__":
unittest.main()

Loading…
Cancel
Save