~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__dirstate_helpers.py

  • Committer: Vincent Ladeuil
  • Date: 2008-09-11 19:36:38 UTC
  • mfrom: (3703 +trunk)
  • mto: (3705.1.1 trunk2)
  • mto: This revision was merged to the branch mainline in revision 3708.
  • Revision ID: v.ladeuil+lp@free.fr-20080911193638-wtjyc1kcmacc6t1f
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
21
21
 
22
22
from bzrlib import (
23
23
    dirstate,
 
24
    errors,
24
25
    tests,
25
26
    )
26
27
from bzrlib.tests import test_dirstate
691
692
        self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
692
693
                         state._dirblock_state)
693
694
 
 
695
    def test_trailing_garbage(self):
 
696
        tree, state, expected = self.create_basic_dirstate()
 
697
        # We can modify the file as long as it hasn't been read yet.
 
698
        f = open('dirstate', 'ab')
 
699
        try:
 
700
            # Add bogus trailing garbage
 
701
            f.write('bogus\n')
 
702
        finally:
 
703
            f.close()
 
704
        e = self.assertRaises(errors.DirstateCorrupt,
 
705
                              state._read_dirblocks_if_needed)
 
706
        # Make sure we mention the bogus characters in the error
 
707
        self.assertContainsRe(str(e), 'bogus')
 
708
 
694
709
 
695
710
class TestCompiledReadDirblocks(TestReadDirblocks):
696
711
    """Test the pyrex implementation of _read_dirblocks"""