~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_versionedfile.py

  • Committer: Robert Collins
  • Date: 2007-09-12 04:21:51 UTC
  • mto: This revision was merged to the branch mainline in revision 2817.
  • Revision ID: robertc@robertcollins.net-20070912042151-o2k78pnf1hdwd2xt
Review feedback.

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
        f = self.reopen_file()
116
116
        verify_file(f)
117
117
 
 
118
    def test_add_unicode_content(self):
 
119
        # unicode content is not permitted in versioned files. 
 
120
        # versioned files version sequences of bytes only.
 
121
        vf = self.get_file()
 
122
        self.assertRaises(errors.BzrBadParameterUnicode,
 
123
            vf.add_lines, 'a', [], ['a\n', u'b\n', 'c\n'])
 
124
        self.assertRaises(
 
125
            (errors.BzrBadParameterUnicode, NotImplementedError),
 
126
            vf.add_lines_with_ghosts, 'a', [], ['a\n', u'b\n', 'c\n'])
 
127
 
118
128
    def test_add_follows_left_matching_blocks(self):
119
129
        """If we change left_matching_blocks, delta changes
120
130
 
132
142
                     left_matching_blocks=[(0, 2, 1), (1, 3, 0)])
133
143
        self.assertEqual(['a\n', 'a\n', 'a\n'], vf.get_lines('3'))
134
144
 
 
145
    def test_inline_newline_throws(self):
 
146
        # \r characters are not permitted in lines being added
 
147
        vf = self.get_file()
 
148
        self.assertRaises(errors.BzrBadParameterContainsNewline, 
 
149
            vf.add_lines, 'a', [], ['a\n\n'])
 
150
        self.assertRaises(
 
151
            (errors.BzrBadParameterContainsNewline, NotImplementedError),
 
152
            vf.add_lines_with_ghosts, 'a', [], ['a\n\n'])
 
153
        # but inline CR's are allowed
 
154
        vf.add_lines('a', [], ['a\r\n'])
 
155
        try:
 
156
            vf.add_lines_with_ghosts('b', [], ['a\r\n'])
 
157
        except NotImplementedError:
 
158
            pass
 
159
 
135
160
    def test_add_reserved(self):
136
161
        vf = self.get_file()
137
162
        self.assertRaises(errors.ReservedId,