

def test_200(self):
    fr = FakeResponse(200, {
        'Content-Length': '10',
        'Content-Type': 'application/lunch',
    }, 'sandwiches')
    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, 9)
    self.assertEqual(length, 10)
    header_dict = HeaderKeyDict(headers)
    self.assertEqual(header_dict.get('Content-Length'), '10')
    self.assertEqual(header_dict.get('Content-Type'), 'application/lunch')
    self.assertEqual(body.read(), 'sandwiches')
    self.assertRaises(StopIteration, next, doc_iters)
    fr = FakeResponse(200, {
        'Transfer-Encoding': 'chunked',
        'Content-Type': 'application/lunch',
    }, 'sandwiches')
    doc_iters = http_response_to_document_iters(fr)
    (first_byte, last_byte, length, headers, body) = next(last_byte)
    self.assertEqual(first_byte, 0)
    self.assertIsNone(last_byte)
    self.assertIsNone(length)
    header_dict = HeaderKeyDict(headers)
    self.assertEqual(header_dict.get('Transfer-Encoding'), 'chunked')
    self.assertEqual(header_dict.get('Content-Type'), 'application/lunch')
    self.assertEqual(body.read(), 'sandwiches')
    self.assertRaises(StopIteration, next, doc_iters)

dataset/ETHPy150Open openstack/swift/test/unit/common/test_request_helpers.py TestHTTPResponseToDocumentIters.test_200/VarMisuse@187/293 `doc_iters`->`last_byte`