/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: Andrew Bennetts
  • Date: 2008-03-27 06:10:18 UTC
  • mfrom: (3309 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3320.
  • Revision ID: andrew.bennetts@canonical.com-20080327061018-dxztpxyv6yoeg3am
Merge from bzr.dev.

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)
437
460
             "http://bug.com/"),
438
461
            str(err))
439
462
 
 
463
    def test_unable_encode_path(self):
 
464
        err = errors.UnableEncodePath('foo', 'executable')
 
465
        self.assertEquals("Unable to encode executable path 'foo' in "
 
466
            "user encoding " + osutils.get_user_encoding(),
 
467
            str(err))
 
468
 
 
469
    def test_unknown_format(self):
 
470
        err = errors.UnknownFormatError('bar', kind='foo')
 
471
        self.assertEquals("Unknown foo format: 'bar'", str(err))
 
472
 
440
473
 
441
474
class PassThroughError(errors.BzrError):
442
475