~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-09-29 08:49:52 UTC
  • mfrom: (3741.2.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20080929084952-3d81d63rru8tt8mm
(vila) Fix python-2.6 various compatibility issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from cStringIO import StringIO
20
20
import difflib
21
21
import gzip
22
 
import sha
23
22
import sys
24
23
 
25
24
from bzrlib import (
27
26
    generate_ids,
28
27
    knit,
29
28
    multiparent,
 
29
    osutils,
30
30
    pack,
31
31
    )
32
32
from bzrlib.errors import (
48
48
    _KnitKeyAccess,
49
49
    make_file_factory,
50
50
    )
51
 
from bzrlib.osutils import split_lines
52
 
from bzrlib.symbol_versioning import one_four
53
51
from bzrlib.tests import (
54
52
    Feature,
55
53
    KnownFailure,
375
373
        return sio.getvalue()
376
374
 
377
375
    def test_valid_knit_data(self):
378
 
        sha1sum = sha.new('foo\nbar\n').hexdigest()
 
376
        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
379
377
        gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
380
378
                                        'foo\n'
381
379
                                        'bar\n'
394
392
        self.assertEqual([(('rev-id-1',), gz_txt, sha1sum)], raw_contents)
395
393
 
396
394
    def test_not_enough_lines(self):
397
 
        sha1sum = sha.new('foo\n').hexdigest()
 
395
        sha1sum = osutils.sha('foo\n').hexdigest()
398
396
        # record says 2 lines data says 1
399
397
        gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
400
398
                                        'foo\n'
412
410
        self.assertEqual([(('rev-id-1',),  gz_txt, sha1sum)], raw_contents)
413
411
 
414
412
    def test_too_many_lines(self):
415
 
        sha1sum = sha.new('foo\nbar\n').hexdigest()
 
413
        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
416
414
        # record says 1 lines data says 2
417
415
        gz_txt = self.create_gz_content('version rev-id-1 1 %s\n'
418
416
                                        'foo\n'
431
429
        self.assertEqual([(('rev-id-1',), gz_txt, sha1sum)], raw_contents)
432
430
 
433
431
    def test_mismatched_version_id(self):
434
 
        sha1sum = sha.new('foo\nbar\n').hexdigest()
 
432
        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
435
433
        gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
436
434
                                        'foo\n'
437
435
                                        'bar\n'
450
448
            knit._read_records_iter_raw(records))
451
449
 
452
450
    def test_uncompressed_data(self):
453
 
        sha1sum = sha.new('foo\nbar\n').hexdigest()
 
451
        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
454
452
        txt = ('version rev-id-1 2 %s\n'
455
453
               'foo\n'
456
454
               'bar\n'
470
468
            knit._read_records_iter_raw(records))
471
469
 
472
470
    def test_corrupted_data(self):
473
 
        sha1sum = sha.new('foo\nbar\n').hexdigest()
 
471
        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
474
472
        gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
475
473
                                        'foo\n'
476
474
                                        'bar\n'
1641
1639
        key_basis = ('bar',)
1642
1640
        key_missing = ('missing',)
1643
1641
        test.add_lines(key, (), ['foo\n'])
1644
 
        key_sha1sum = sha.new('foo\n').hexdigest()
 
1642
        key_sha1sum = osutils.sha('foo\n').hexdigest()
1645
1643
        sha1s = test.get_sha1s([key])
1646
1644
        self.assertEqual({key: key_sha1sum}, sha1s)
1647
1645
        self.assertEqual([], basis.calls)
1649
1647
        # directly (rather than via text reconstruction) so that remote servers
1650
1648
        # etc don't have to answer with full content.
1651
1649
        basis.add_lines(key_basis, (), ['foo\n', 'bar\n'])
1652
 
        basis_sha1sum = sha.new('foo\nbar\n').hexdigest()
 
1650
        basis_sha1sum = osutils.sha('foo\nbar\n').hexdigest()
1653
1651
        basis.calls = []
1654
1652
        sha1s = test.get_sha1s([key, key_missing, key_basis])
1655
1653
        self.assertEqual({key: key_sha1sum,