~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http_response.py

  • Committer: Patch Queue Manager
  • Date: 2013-05-25 00:23:24 UTC
  • mfrom: (6575.1.3 1184021)
  • Revision ID: pqm@pqm.ubuntu.com-20130525002324-a3vwfemjm3vlhspz
(vila) Add __iter__ to http ResponseFile (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
        pass
76
76
 
77
77
 
 
78
class TestResponseFileIter(tests.TestCase):
 
79
 
 
80
    def test_iter_empty(self):
 
81
        f = response.ResponseFile('empty', StringIO())
 
82
        self.assertEqual([], list(f))
 
83
 
 
84
    def test_iter_many(self):
 
85
        f = response.ResponseFile('many', StringIO('0\n1\nboo!\n'))
 
86
        self.assertEqual(['0\n', '1\n', 'boo!\n'], list(f))
 
87
 
 
88
 
78
89
class TestHTTPConnection(tests.TestCase):
79
90
 
80
91
    def test_cleanup_pipe(self):
137
148
 
138
149
    def test_read_zero(self):
139
150
        f = self._file
140
 
        start = self.first_range_start
141
151
        self.assertEquals('', f.read(0))
142
152
        f.seek(10, 1)
143
153
        self.assertEquals('', f.read(0))
371
381
 
372
382
    def test_seek_across_ranges(self):
373
383
        f = self._file
374
 
        start = self.first_range_start
375
384
        f.seek(126) # skip the two first ranges
376
385
        self.assertEquals('AB', f.read(2))
377
386
 
378
387
    def test_checked_read_dont_overflow_buffers(self):
379
388
        f = self._file
380
 
        start = self.first_range_start
381
389
        # We force a very low value to exercise all code paths in _checked_read
382
390
        f._discarded_buf_size = 8
383
391
        f.seek(126) # skip the two first ranges