/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

  • Committer: Martin Pool
  • Date: 2007-08-20 05:53:39 UTC
  • mfrom: (2727 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2730.
  • Revision ID: mbp@sourcefrog.net-20070820055339-uzei7f7i7jo6tugg
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        self.assertEqualDiff('The prefix foo is in the help search path twice.',
47
47
            str(error))
48
48
 
 
49
    def test_incompatibleAPI(self):
 
50
        error = errors.IncompatibleAPI("module", (1, 2, 3), (4, 5, 6), (7, 8, 9))
 
51
        self.assertEqualDiff(
 
52
            'The API for "module" is not compatible with "(1, 2, 3)". '
 
53
            'It supports versions "(4, 5, 6)" to "(7, 8, 9)".',
 
54
            str(error))
 
55
 
 
56
    def test_in_process_transport(self):
 
57
        error = errors.InProcessTransport('fpp')
 
58
        self.assertEqualDiff(
 
59
            "The transport 'fpp' is only accessible within this process.",
 
60
            str(error))
 
61
 
49
62
    def test_inventory_modified(self):
50
63
        error = errors.InventoryModified("a tree to be repred")
51
64
        self.assertEqualDiff("The current inventory for the tree 'a tree to "
159
172
                             repo.bzrdir.root_transport.base,
160
173
                             str(error))
161
174
 
 
175
    def test_read_error(self):
 
176
        # a unicode path to check that %r is being used.
 
177
        path = u'a path'
 
178
        error = errors.ReadError(path)
 
179
        self.assertEqualDiff("Error reading from u'a path'.", str(error))
 
180
 
 
181
    def test_bad_index_format_signature(self):
 
182
        error = errors.BadIndexFormatSignature("foo", "bar")
 
183
        self.assertEqual("foo is not an index of type bar.",
 
184
            str(error))
 
185
 
 
186
    def test_bad_index_data(self):
 
187
        error = errors.BadIndexData("foo")
 
188
        self.assertEqual("Error in data for index foo.",
 
189
            str(error))
 
190
 
 
191
    def test_bad_index_duplicate_key(self):
 
192
        error = errors.BadIndexDuplicateKey("foo", "bar")
 
193
        self.assertEqual("The key 'foo' is already in index 'bar'.",
 
194
            str(error))
 
195
 
 
196
    def test_bad_index_key(self):
 
197
        error = errors.BadIndexKey("foo")
 
198
        self.assertEqual("The key 'foo' is not a valid key.",
 
199
            str(error))
 
200
 
 
201
    def test_bad_index_options(self):
 
202
        error = errors.BadIndexOptions("foo")
 
203
        self.assertEqual("Could not parse options for index foo.",
 
204
            str(error))
 
205
 
 
206
    def test_bad_index_value(self):
 
207
        error = errors.BadIndexValue("foo")
 
208
        self.assertEqual("The value 'foo' is not a valid value.",
 
209
            str(error))
 
210
 
162
211
    def test_bzrnewerror_is_deprecated(self):
163
212
        class DeprecatedError(errors.BzrNewError):
164
213
            pass
198
247
            str(error))
199
248
 
200
249
    def test_transport_not_possible(self):
201
 
        e = errors.TransportNotPossible('readonly', 'original error')
202
 
        self.assertEqual('Transport operation not possible:'
203
 
                         ' readonly original error', str(e))
 
250
        error = errors.TransportNotPossible('readonly', 'original error')
 
251
        self.assertEqualDiff('Transport operation not possible:'
 
252
                         ' readonly original error', str(error))
204
253
 
205
254
    def assertSocketConnectionError(self, expected, *args, **kwargs):
206
255
        """Check the formatting of a SocketConnectionError exception"""
266
315
            "Could not understand response from smart server: ('not yes',)",
267
316
            str(e))
268
317
 
 
318
    def test_unknown_container_format(self):
 
319
        """Test the formatting of UnknownContainerFormatError."""
 
320
        e = errors.UnknownContainerFormatError('bad format string')
 
321
        self.assertEqual(
 
322
            "Unrecognised container format: 'bad format string'",
 
323
            str(e))
 
324
 
 
325
    def test_unexpected_end_of_container(self):
 
326
        """Test the formatting of UnexpectedEndOfContainerError."""
 
327
        e = errors.UnexpectedEndOfContainerError()
 
328
        self.assertEqual(
 
329
            "Unexpected end of container stream", str(e))
 
330
 
 
331
    def test_unknown_record_type(self):
 
332
        """Test the formatting of UnknownRecordTypeError."""
 
333
        e = errors.UnknownRecordTypeError("X")
 
334
        self.assertEqual(
 
335
            "Unknown record type: 'X'",
 
336
            str(e))
 
337
 
 
338
    def test_invalid_record(self):
 
339
        """Test the formatting of InvalidRecordError."""
 
340
        e = errors.InvalidRecordError("xxx")
 
341
        self.assertEqual(
 
342
            "Invalid record: xxx",
 
343
            str(e))
 
344
 
 
345
    def test_container_has_excess_data(self):
 
346
        """Test the formatting of ContainerHasExcessDataError."""
 
347
        e = errors.ContainerHasExcessDataError("excess bytes")
 
348
        self.assertEqual(
 
349
            "Container has data after end marker: 'excess bytes'",
 
350
            str(e))
 
351
 
 
352
    def test_duplicate_record_name_error(self):
 
353
        """Test the formatting of DuplicateRecordNameError."""
 
354
        e = errors.DuplicateRecordNameError(u"n\xe5me".encode('utf-8'))
 
355
        self.assertEqual(
 
356
            "Container has multiple records with the same name: \"n\xc3\xa5me\"",
 
357
            str(e))
 
358
 
269
359
 
270
360
class PassThroughError(errors.BzrError):
271
361
    
312
402
        e = ErrorWithBadFormat(not_thing='x')
313
403
        self.assertStartsWith(
314
404
            str(e), 'Unprintable exception ErrorWithBadFormat')
315