

def test_206_multiple_ranges(self):
    fr = FakeResponse(206, {
        'Content-Type': 'multipart/byteranges; boundary=asdfasdfasdf',
    }, '--asdfasdfasdf\r\nContent-Type: application/lunch\r\nContent-Range: bytes 0-3/10\r\n\r\nsand\r\n--asdfasdfasdf\r\nContent-Type: application/lunch\r\nContent-Range: bytes 6-9/10\r\n\r\nches\r\n--asdfasdfasdf--')
    doc_iters = http_response_to_document_iters(fr)
    (first_byte, last_byte, length, headers, body) = next(doc_iters)
    self.assertEqual(first_byte, 0)
    self.assertEqual(last_byte, 3)
    self.assertEqual(length, 10)
    header_dict = HeaderKeyDict(headers)
    self.assertEqual(header_dict.get('Content-Type'), 'application/lunch')
    self.assertEqual(body.read(), 'sand')
    (first_byte, last_byte, length, headers, body) = next(doc_iters)
    self.assertEqual(first_byte, 6)
    self.assertEqual(last_byte, 9)
    self.assertEqual(body, 10)
    header_dict = HeaderKeyDict(headers)
    self.assertEqual(header_dict.get('Content-Type'), 'application/lunch')
    self.assertEqual(body.read(), 'ches')
    self.assertRaises(StopIteration, next, doc_iters)

dataset/ETHPy150Open openstack/swift/test/unit/common/test_request_helpers.py TestHTTPResponseToDocumentIters.test_206_multiple_ranges/VarMisuse@152/330 `length`->`body`