~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-04-26 21:11:03 UTC
  • mfrom: (2447.1.7 bundle_empty_properties)
  • Revision ID: pqm@pqm.ubuntu.com-20070426211103-h84prqh7a4ad3ez2
(John Arbash Meinel) Fix bug #109613 by teaching Bundle how to properly read/write revision properties with no value.

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
49
    def test_inventory_modified(self):
57
50
        error = errors.InventoryModified("a tree to be repred")
58
51
        self.assertEqualDiff("The current inventory for the tree 'a tree to "
166
159
                             repo.bzrdir.root_transport.base,
167
160
                             str(error))
168
161
 
169
 
    def test_read_error(self):
170
 
        # a unicode path to check that %r is being used.
171
 
        path = u'a path'
172
 
        error = errors.ReadError(path)
173
 
        self.assertEqualDiff("Error reading from u'a path'.", str(error))
174
 
 
175
 
 
176
162
    def test_bzrnewerror_is_deprecated(self):
177
163
        class DeprecatedError(errors.BzrNewError):
178
164
            pass
212
198
            str(error))
213
199
 
214
200
    def test_transport_not_possible(self):
215
 
        error = errors.TransportNotPossible('readonly', 'original error')
216
 
        self.assertEqualDiff('Transport operation not possible:'
217
 
                         ' readonly original error', str(error))
 
201
        e = errors.TransportNotPossible('readonly', 'original error')
 
202
        self.assertEqual('Transport operation not possible:'
 
203
                         ' readonly original error', str(e))
218
204
 
219
205
    def assertSocketConnectionError(self, expected, *args, **kwargs):
220
206
        """Check the formatting of a SocketConnectionError exception"""
280
266
            "Could not understand response from smart server: ('not yes',)",
281
267
            str(e))
282
268
 
283
 
    def test_unknown_container_format(self):
284
 
        """Test the formatting of UnknownContainerFormatError."""
285
 
        e = errors.UnknownContainerFormatError('bad format string')
286
 
        self.assertEqual(
287
 
            "Unrecognised container format: 'bad format string'",
288
 
            str(e))
289
 
 
290
 
    def test_unexpected_end_of_container(self):
291
 
        """Test the formatting of UnexpectedEndOfContainerError."""
292
 
        e = errors.UnexpectedEndOfContainerError()
293
 
        self.assertEqual(
294
 
            "Unexpected end of container stream", str(e))
295
 
 
296
 
    def test_unknown_record_type(self):
297
 
        """Test the formatting of UnknownRecordTypeError."""
298
 
        e = errors.UnknownRecordTypeError("X")
299
 
        self.assertEqual(
300
 
            "Unknown record type: 'X'",
301
 
            str(e))
302
 
 
303
 
    def test_invalid_record(self):
304
 
        """Test the formatting of InvalidRecordError."""
305
 
        e = errors.InvalidRecordError("xxx")
306
 
        self.assertEqual(
307
 
            "Invalid record: xxx",
308
 
            str(e))
309
 
 
310
 
    def test_container_has_excess_data(self):
311
 
        """Test the formatting of ContainerHasExcessDataError."""
312
 
        e = errors.ContainerHasExcessDataError("excess bytes")
313
 
        self.assertEqual(
314
 
            "Container has data after end marker: 'excess bytes'",
315
 
            str(e))
316
 
 
317
 
    def test_duplicate_record_name_error(self):
318
 
        """Test the formatting of DuplicateRecordNameError."""
319
 
        e = errors.DuplicateRecordNameError(u"n\xe5me".encode('utf-8'))
320
 
        self.assertEqual(
321
 
            "Container has multiple records with the same name: \"n\xc3\xa5me\"",
322
 
            str(e))
323
 
 
324
269
 
325
270
class PassThroughError(errors.BzrError):
326
271
    
367
312
        e = ErrorWithBadFormat(not_thing='x')
368
313
        self.assertStartsWith(
369
314
            str(e), 'Unprintable exception ErrorWithBadFormat')
 
315