def test_pyusb_device_get_vendor_and_product_ids(self):
     """
     Test that the VID and PID supplied with the constructor is returned.
     """
     vendor_id = 0xE5F6
     product_id = 0x1AB2
     interface_number = 0
     device = PyUsbDevice(vendor_id, product_id, interface_number)
     self.assertEqual(device.get_vendor_id(), vendor_id)
     self.assertEqual(device.get_product_id(), product_id)
 def test_pyusb_device_get_packet_size_unavailable_if_closed(self):
     """
     PyUSB's packet size is only available when the device is connected.
     """
     vendor_id = 0
     product_id = 0
     interface_number = 0
     device = PyUsbDevice(vendor_id, product_id, interface_number)
     self.assertFalse(device.is_open())
     self.assertRaises(DeviceError, device.get_packet_size)
 def test_pyusb_device_no_such_device(self):
     """
     Operations must fail if there's no such device.
     """
     vendor_id = 0
     product_id = 0
     interface_number = 0
     device = PyUsbDevice(vendor_id, product_id, interface_number)
     self.assertRaises(IOError, device.open)
     self.assertFalse(device.is_open())
     self.assertRaises(DeviceError, device.send, "foo")
     self.assertRaises(DeviceError, device.receive)