/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: John Arbash Meinel
  • Date: 2008-06-05 16:27:16 UTC
  • mfrom: (3475 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3476.
  • Revision ID: john@arbash-meinel.com-20080605162716-a3hn238tnctbfd8j
merge bzr.dev, resolve NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib import (
22
22
    bzrdir,
23
23
    errors,
 
24
    osutils,
24
25
    symbol_versioning,
25
26
    urlutils,
26
27
    )
51
52
        self.assertEqualDiff('The prefix foo is in the help search path twice.',
52
53
            str(error))
53
54
 
 
55
    def test_ghost_revisions_have_no_revno(self):
 
56
        error = errors.GhostRevisionsHaveNoRevno('target', 'ghost_rev')
 
57
        self.assertEqualDiff("Could not determine revno for {target} because"
 
58
                             " its ancestry shows a ghost at {ghost_rev}",
 
59
                             str(error))
 
60
 
54
61
    def test_incompatibleAPI(self):
55
62
        error = errors.IncompatibleAPI("module", (1, 2, 3), (4, 5, 6), (7, 8, 9))
56
63
        self.assertEqualDiff(
174
181
                             " tree atree.", str(error))
175
182
        self.assertIsInstance(error, errors.NoSuchRevision)
176
183
 
 
184
    def test_not_stacked(self):
 
185
        error = errors.NotStacked('a branch')
 
186
        self.assertEqualDiff("The branch 'a branch' is not stacked.",
 
187
            str(error))
 
188
 
177
189
    def test_not_write_locked(self):
178
190
        error = errors.NotWriteLocked('a thing to repr')
179
191
        self.assertEqualDiff("'a thing to repr' is not write locked but needs "
180
192
            "to be.",
181
193
            str(error))
182
194
 
183
 
    def test_read_only_lock_error(self):
184
 
        error = self.applyDeprecated(symbol_versioning.zero_ninetytwo,
185
 
            errors.ReadOnlyLockError, 'filename', 'error message')
186
 
        self.assertEqualDiff("Cannot acquire write lock on filename."
187
 
                             " error message", str(error))
188
 
 
189
195
    def test_lock_failed(self):
190
196
        error = errors.LockFailed('http://canonical.com/', 'readonly transport')
191
197
        self.assertEqualDiff("Cannot lock http://canonical.com/: readonly transport",
199
205
            "the currently open request.",
200
206
            str(error))
201
207
 
 
208
    def test_unavailable_representation(self):
 
209
        error = errors.UnavailableRepresentation(('key',), "mpdiff", "fulltext")
 
210
        self.assertEqualDiff("The encoding 'mpdiff' is not available for key "
 
211
            "('key',) which is encoded as 'fulltext'.",
 
212
            str(error))
 
213
 
202
214
    def test_unknown_hook(self):
203
215
        error = errors.UnknownHook("branch", "foo")
204
216
        self.assertEqualDiff("The branch hook 'foo' is unknown in this version"
209
221
            " of bzrlib.",
210
222
            str(error))
211
223
 
 
224
    def test_unstackable_branch_format(self):
 
225
        format = u'foo'
 
226
        url = "/foo"
 
227
        error = errors.UnstackableBranchFormat(format, url)
 
228
        self.assertEqualDiff(
 
229
            "The branch '/foo'(foo) is not a stackable format. "
 
230
            "You will need to upgrade the branch to permit branch stacking.",
 
231
            str(error))
 
232
 
 
233
    def test_unstackable_repository_format(self):
 
234
        format = u'foo'
 
235
        url = "/foo"
 
236
        error = errors.UnstackableRepositoryFormat(format, url)
 
237
        self.assertEqualDiff(
 
238
            "The repository '/foo'(foo) is not a stackable format. "
 
239
            "You will need to upgrade the repository to permit branch stacking.",
 
240
            str(error))
 
241
 
212
242
    def test_up_to_date(self):
213
243
        error = errors.UpToDateFormat(bzrdir.BzrDirFormat4())
214
244
        self.assertEqualDiff("The branch format Bazaar-NG branch, "
445
475
            "Unable to create symlink u'\\xb5' on this platform",
446
476
            str(err))
447
477
 
 
478
    def test_invalid_url_join(self):
 
479
        """Test the formatting of InvalidURLJoin."""
 
480
        e = errors.InvalidURLJoin('Reason', 'base path', ('args',))
 
481
        self.assertEqual(
 
482
            "Invalid URL join request: Reason: 'base path' + ('args',)",
 
483
            str(e))
 
484
 
448
485
    def test_incorrect_url(self):
449
486
        err = errors.InvalidBugTrackerURL('foo', 'http://bug.com/')
450
487
        self.assertEquals(
452
489
             "http://bug.com/"),
453
490
            str(err))
454
491
 
 
492
    def test_unable_encode_path(self):
 
493
        err = errors.UnableEncodePath('foo', 'executable')
 
494
        self.assertEquals("Unable to encode executable path 'foo' in "
 
495
            "user encoding " + osutils.get_user_encoding(),
 
496
            str(err))
 
497
 
 
498
    def test_unknown_format(self):
 
499
        err = errors.UnknownFormatError('bar', kind='foo')
 
500
        self.assertEquals("Unknown foo format: 'bar'", str(err))
 
501
 
455
502
 
456
503
class PassThroughError(errors.BzrError):
457
504