Skip to content
Myr

Make Response objects iterable.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Cory Benfield · committed by Cory Benfield · parent 231e343 · Browse files · 2 files+10 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−0 removed

  • other:+10 added−0 removed

2 files+10 added−0 removed

modified:requests/models.py+4 added
484 unmodified lines
485 def __nonzero__(self):486 """Returns true if :attr:`status_code` is 'OK'."""487 return self.ok488489 def __iter__(self):490 """Returns the current object."""491 return self.iter_content(128)492493 @property494 def ok(self):495 try:496 self.raise_for_status()
170 unmodified lines
modified:test_requests.py+6 added
323 unmodified lines
324 def test_time_elapsed_blank(self):325 r = requests.get(httpbin('get'))326 self.assertTrue(r.elapsed.total_seconds() > 0.0)327328 def test_response_is_iterable(self):329 r = requests.Response()330 io = StringIO.StringIO('abc')331 r.raw = io332 self.assertTrue(iter(r).next())333 io.close()334335if __name__ == '__main__':336 unittest.main()