~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#            and others
4
4
#
21
21
from bzrlib import (
22
22
    bzrdir,
23
23
    errors,
 
24
    osutils,
24
25
    symbol_versioning,
 
26
    urlutils,
25
27
    )
26
28
from bzrlib.tests import TestCase, TestCaseWithTransport
27
29
 
28
30
 
29
31
class TestErrors(TestCaseWithTransport):
30
32
 
 
33
    def test_corrupt_dirstate(self):
 
34
        error = errors.CorruptDirstate('path/to/dirstate', 'the reason why')
 
35
        self.assertEqualDiff(
 
36
            "Inconsistency in dirstate file path/to/dirstate.\n"
 
37
            "Error: the reason why",
 
38
            str(error))
 
39
 
31
40
    def test_disabled_method(self):
32
41
        error = errors.DisabledMethod("class name")
33
42
        self.assertEqualDiff(
50
59
            'It supports versions "(4, 5, 6)" to "(7, 8, 9)".',
51
60
            str(error))
52
61
 
 
62
    def test_inconsistent_delta(self):
 
63
        error = errors.InconsistentDelta('path', 'file-id', 'reason for foo')
 
64
        self.assertEqualDiff(
 
65
            "An inconsistent delta was supplied involving 'path', 'file-id'\n"
 
66
            "reason: reason for foo",
 
67
            str(error))
 
68
 
53
69
    def test_in_process_transport(self):
54
70
        error = errors.InProcessTransport('fpp')
55
71
        self.assertEqualDiff(
121
137
        error = errors.MediumNotConnected("a medium")
122
138
        self.assertEqualDiff(
123
139
            "The medium 'a medium' is not connected.", str(error))
124
 
        
 
140
 
 
141
    def test_no_public_branch(self):
 
142
        b = self.make_branch('.')
 
143
        error = errors.NoPublicBranch(b)
 
144
        url = urlutils.unescape_for_display(b.base, 'ascii')
 
145
        self.assertEqualDiff(
 
146
            'There is no public branch set for "%s".' % url, str(error))
 
147
 
125
148
    def test_no_repo(self):
126
149
        dir = bzrdir.BzrDir.create(self.get_url())
127
150
        error = errors.NoRepositoryPresent(dir)
430
453
             "http://bug.com/"),
431
454
            str(err))
432
455
 
 
456
    def test_unable_encode_path(self):
 
457
        err = errors.UnableEncodePath('foo', 'executable')
 
458
        self.assertEquals("Unable to encode executable path 'foo' in "
 
459
            "user encoding " + osutils.get_user_encoding(),
 
460
            str(err))
 
461
 
 
462
    def test_unknown_format(self):
 
463
        err = errors.UnknownFormatError('bar', kind='foo')
 
464
        self.assertEquals("Unknown foo format: 'bar'", str(err))
 
465
 
433
466
 
434
467
class PassThroughError(errors.BzrError):
435
468