~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
25
25
    bzrdir,
26
26
    errors,
27
27
    osutils,
28
 
    symbol_versioning,
29
28
    urlutils,
30
29
    )
31
 
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
 
30
from bzrlib.tests import (
 
31
    TestCase,
 
32
    TestCaseWithTransport,
 
33
    TestSkipped,
 
34
    )
32
35
 
33
36
 
34
37
class TestErrors(TestCaseWithTransport):
159
162
            "cannot be broken.",
160
163
            str(error))
161
164
 
 
165
    def test_lock_corrupt(self):
 
166
        error = errors.LockCorrupt("corruption info")
 
167
        self.assertEqualDiff("Lock is apparently held, but corrupted: "
 
168
            "corruption info\n"
 
169
            "Use 'bzr break-lock' to clear it",
 
170
            str(error))
 
171
 
162
172
    def test_knit_data_stream_incompatible(self):
163
173
        error = errors.KnitDataStreamIncompatible(
164
174
            'stream format', 'target format')
290
300
            str(error))
291
301
 
292
302
    def test_up_to_date(self):
293
 
        error = errors.UpToDateFormat(bzrdir.BzrDirFormat4())
294
 
        self.assertEqualDiff("The branch format All-in-one "
295
 
                             "format 4 is already at the most "
296
 
                             "recent format.",
297
 
                             str(error))
 
303
        error = errors.UpToDateFormat("someformat")
 
304
        self.assertEqualDiff(
 
305
            "The branch format someformat is already at the most "
 
306
            "recent format.", str(error))
298
307
 
299
308
    def test_corrupt_repository(self):
300
309
        repo = self.make_repository('.')
665
674
        err = errors.NotBranchError('path', bzrdir=bzrdir)
666
675
        self.assertEqual('Not a branch: "path".', str(err))
667
676
 
 
677
    def test_not_branch_bzrdir_with_recursive_not_branch_error(self):
 
678
        class FakeBzrDir(object):
 
679
            def open_repository(self):
 
680
                # str() on the NotBranchError will trigger a call to this,
 
681
                # which in turn will another, identical NotBranchError.
 
682
                raise errors.NotBranchError('path', bzrdir=FakeBzrDir())
 
683
        err = errors.NotBranchError('path', bzrdir=FakeBzrDir())
 
684
        self.assertEqual('Not a branch: "path".', str(err))
 
685
 
668
686
    def test_not_branch_laziness(self):
669
687
        real_bzrdir = self.make_bzrdir('path')
670
688
        class FakeBzrDir(object):