~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

Move doctest import to increase speed

Show diffs side-by-side

added added

removed removed

Lines of Context:
272
272
        self.assertEquals(origins[0], ('text-c', 'z\n'))
273
273
        self.assertEquals(origins[1], ('text-b', 'c\n'))
274
274
 
275
 
    def test_get_line_delta_texts(self):
276
 
        """Make sure we can call get_texts on text with reused line deltas"""
277
 
        k1 = KnitVersionedFile('test1', get_transport('.'), 
278
 
                               factory=KnitPlainFactory(), create=True)
279
 
        for t in range(3):
280
 
            if t == 0:
281
 
                parents = []
282
 
            else:
283
 
                parents = ['%d' % (t-1)]
284
 
            k1.add_lines('%d' % t, parents, ['hello\n'] * t)
285
 
        k1.get_texts(('%d' % t) for t in range(3))
 
275
    def test_extraction_reads_components_once(self):
 
276
        t = MemoryTransport()
 
277
        instrumented_t = TransportLogger(t)
 
278
        k1 = KnitVersionedFile('id', instrumented_t, create=True, delta=True)
 
279
        # should read the index
 
280
        self.assertEqual([('id.kndx',)], instrumented_t._calls)
 
281
        instrumented_t._calls = []
 
282
        # add a text       
 
283
        k1.add_lines('base', [], ['text\n'])
 
284
        # should not have read at all
 
285
        self.assertEqual([], instrumented_t._calls)
 
286
 
 
287
        # add a text
 
288
        k1.add_lines('sub', ['base'], ['text\n', 'text2\n'])
 
289
        # should not have read at all
 
290
        self.assertEqual([], instrumented_t._calls)
 
291
        
 
292
        # read a text
 
293
        k1.get_lines('sub')
 
294
        # should not have read at all
 
295
        self.assertEqual([], instrumented_t._calls)
 
296
 
 
297
        # clear the cache
 
298
        k1.clear_cache()
 
299
 
 
300
        # read a text
 
301
        k1.get_lines('base')
 
302
        # should have read a component
 
303
        # should not have read the first component only
 
304
        self.assertEqual([('id.knit', [(0, 87)])], instrumented_t._calls)
 
305
        instrumented_t._calls = []
 
306
        # read again
 
307
        k1.get_lines('base')
 
308
        # should not have read at all
 
309
        self.assertEqual([], instrumented_t._calls)
 
310
        # and now read the other component
 
311
        k1.get_lines('sub')
 
312
        # should have read the second component
 
313
        self.assertEqual([('id.knit', [(87, 93)])], instrumented_t._calls)
 
314
        instrumented_t._calls = []
 
315
 
 
316
        # clear the cache
 
317
        k1.clear_cache()
 
318
        # add a text cold 
 
319
        k1.add_lines('sub2', ['base'], ['text\n', 'text3\n'])
 
320
        # should read the first component only
 
321
        self.assertEqual([('id.knit', [(0, 87)])], instrumented_t._calls)
286
322
        
287
323
    def test_iter_lines_reads_in_order(self):
288
324
        t = MemoryTransport()