~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_branch.py

  • Committer: Jonathan Riddell
  • Date: 2011-09-20 13:31:00 UTC
  • mto: This revision was merged to the branch mainline in revision 6153.
  • Revision ID: jriddell@canonical.com-20110920133100-kpsomvcnjoxv6n6b
syntax fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
    def test_branch_broken_pack(self):
67
67
        """branching with a corrupted pack file."""
68
68
        self.example_branch('a')
69
 
        # add some corruption
70
 
        packs_dir = 'a/.bzr/repository/packs/'
71
 
        fname = packs_dir + os.listdir(packs_dir)[0]
 
69
        #now add some random corruption
 
70
        fname = 'a/.bzr/repository/packs/' + os.listdir('a/.bzr/repository/packs')[0]
72
71
        with open(fname, 'rb+') as f:
73
 
            # Start from the end of the file to avoid choosing a place bigger
74
 
            # than the file itself.
75
 
            f.seek(-5, os.SEEK_END)
76
 
            c = f.read(1)
77
 
            f.seek(-5, os.SEEK_END)
78
 
            # Make sure we inject a value different than the one we just read
79
 
            if c == '\xFF':
80
 
                corrupt = '\x00'
81
 
            else:
82
 
                corrupt = '\xFF'
83
 
            f.write(corrupt) # make sure we corrupt something
 
72
            f.seek(750)
 
73
            f.write("\xff")
84
74
        self.run_bzr_error(['Corruption while decompressing repository file'], 
85
75
                            'branch a b', retcode=3)
86
76