~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: 2010-01-15 05:43:42 UTC
  • mfrom: (4734.4.13 bug-440952-bzrdir)
  • Revision ID: pqm@pqm.ubuntu.com-20100115054342-o6ar5y4ch9tcnzyi
(andrew) Give 'location is a repository' hint for NotBranchError
        (#440952).

Show diffs side-by-side

added added

removed removed

Lines of Context:
623
623
        self.assertEqual(
624
624
            'Repository dummy repo cannot suspend a write group.', str(err))
625
625
 
 
626
    def test_not_branch_no_args(self):
 
627
        err = errors.NotBranchError('path')
 
628
        self.assertEqual('Not a branch: "path".', str(err))
 
629
 
 
630
    def test_not_branch_bzrdir_with_repo(self):
 
631
        bzrdir = self.make_repository('repo').bzrdir
 
632
        err = errors.NotBranchError('path', bzrdir=bzrdir)
 
633
        self.assertEqual(
 
634
            'Not a branch: "path": location is a repository.', str(err))
 
635
 
 
636
    def test_not_branch_bzrdir_without_repo(self):
 
637
        bzrdir = self.make_bzrdir('bzrdir')
 
638
        err = errors.NotBranchError('path', bzrdir=bzrdir)
 
639
        self.assertEqual('Not a branch: "path".', str(err))
 
640
 
 
641
    def test_not_branch_laziness(self):
 
642
        real_bzrdir = self.make_bzrdir('path')
 
643
        class FakeBzrDir(object):
 
644
            def __init__(self):
 
645
                self.calls = []
 
646
            def open_repository(self):
 
647
                self.calls.append('open_repository')
 
648
                raise errors.NoRepositoryPresent(real_bzrdir)
 
649
        fake_bzrdir = FakeBzrDir()
 
650
        err = errors.NotBranchError('path', bzrdir=fake_bzrdir)
 
651
        self.assertEqual([], fake_bzrdir.calls)
 
652
        str(err)
 
653
        self.assertEqual(['open_repository'], fake_bzrdir.calls)
 
654
        # Stringifying twice doesn't try to open a repository twice.
 
655
        str(err)
 
656
        self.assertEqual(['open_repository'], fake_bzrdir.calls)
 
657
 
626
658
 
627
659
class PassThroughError(errors.BzrError):
628
660