@methodtrace(utils.logger)
    def test_write_read(self):
        altsettings = [devinfo.INTF_BULK, devinfo.INTF_INTR]
        eps = [devinfo.EP_BULK, devinfo.EP_INTR]
        data_len = [8, 8]

        if utils.is_iso_test_allowed():
            altsettings.append(devinfo.INTF_ISO)
            eps.append(devinfo.EP_ISO)
            data_len.append(64)

        def delay(alt):
            # Hack to avoid two consecutive isochronous transfers to fail
            if alt == devinfo.INTF_ISO and utils.is_windows():
                time.sleep(0.5)

        for alt, length in zip(altsettings, data_len):
            self.dev.set_interface_altsetting(0, alt)
            for data in make_data_list(length):
                adata = utils.to_array(data)
                length = utils.data_len(data)
                buff = usb.util.create_buffer(length)

                try:
                    ret = self.dev.write(eps[alt], data)
                except NotImplementedError:
                    continue

                self.assertEqual(ret, length)

                self.assertEqual(
                    ret,
                    length,
                    'Failed to write data: ' + \
                        str(data) + ', in interface = ' + \
                        str(alt))

                try:
                    ret = self.dev.read(eps[alt] | usb.util.ENDPOINT_IN, length)
                except __HOLE__:
                    continue

                self.assertTrue(
                    utils.array_equals(ret, adata),
                    str(ret) + ' != ' + \
                        str(adata) + ', in interface = ' + \
                        str(alt))

                delay(alt)

                try:
                    ret = self.dev.write(eps[alt], data)
                except NotImplementedError:
                    continue

                self.assertEqual(ret, length)

                self.assertEqual(
                    ret,
                    length,
                    'Failed to write data: ' + \
                        str(data) + ', in interface = ' + \
                        str(alt))

                try:
                    ret = self.dev.read(eps[alt] | usb.util.ENDPOINT_IN, buff)
                except NotImplementedError:
                    continue

                self.assertEqual(ret, length)

                self.assertTrue(
                    utils.array_equals(buff, adata),
                     str(buff) + ' != ' + \
                        str(adata) + ', in interface = ' + \
                        str(alt))

                delay(alt)
dataset/ETHPy150Open walac/pyusb/tests/test_integration.py/DeviceTest.test_write_read