/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: Marius Kruger
  • Date: 2007-08-12 08:15:15 UTC
  • mfrom: (2695 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2979.
  • Revision ID: amanic@gmail.com-20070812081515-vgekipfhohcuj6rn
merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
 
3
#            and others
3
4
#
4
5
# This program is free software; you can redistribute it and/or modify
5
6
# it under the terms of the GNU General Public License as published by
45
46
        self.assertEqualDiff('The prefix foo is in the help search path twice.',
46
47
            str(error))
47
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
 
48
62
    def test_inventory_modified(self):
49
63
        error = errors.InventoryModified("a tree to be repred")
50
64
        self.assertEqualDiff("The current inventory for the tree 'a tree to "
158
172
                             repo.bzrdir.root_transport.base,
159
173
                             str(error))
160
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
 
161
211
    def test_bzrnewerror_is_deprecated(self):
162
212
        class DeprecatedError(errors.BzrNewError):
163
213
            pass
197
247
            str(error))
198
248
 
199
249
    def test_transport_not_possible(self):
200
 
        e = errors.TransportNotPossible('readonly', 'original error')
201
 
        self.assertEqual('Transport operation not possible:'
202
 
                         ' 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))
203
253
 
204
254
    def assertSocketConnectionError(self, expected, *args, **kwargs):
205
255
        """Check the formatting of a SocketConnectionError exception"""
265
315
            "Could not understand response from smart server: ('not yes',)",
266
316
            str(e))
267
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
 
268
359
 
269
360
class PassThroughError(errors.BzrError):
270
361
    
311
402
        e = ErrorWithBadFormat(not_thing='x')
312
403
        self.assertStartsWith(
313
404
            str(e), 'Unprintable exception ErrorWithBadFormat')
314