~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

  • Committer: Jelmer Vernooij
  • Date: 2009-04-17 00:10:45 UTC
  • mto: This revision was merged to the branch mainline in revision 4299.
  • Revision ID: jelmer@samba.org-20090417001045-8elg0p1apb0w8bnm
Don't retrieve the tree if log is called on the root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
 
2
#   Authors: Robert Collins <robert.collins@canonical.com>
 
3
#            and others
2
4
#
3
5
# This program is free software; you can redistribute it and/or modify
4
6
# it under the terms of the GNU General Public License as published by
16
18
 
17
19
"""Tests for the formatting and construction of errors."""
18
20
 
19
 
import socket
20
21
import sys
21
 
 
22
22
from bzrlib import (
23
23
    bzrdir,
24
24
    errors,
87
87
            "reason: reason for foo",
88
88
            str(error))
89
89
 
90
 
    def test_inconsistent_delta_delta(self):
91
 
        error = errors.InconsistentDeltaDelta([], 'reason')
92
 
        self.assertEqualDiff(
93
 
            "An inconsistent delta was supplied: []\nreason: reason",
94
 
            str(error))
95
 
 
96
90
    def test_in_process_transport(self):
97
91
        error = errors.InProcessTransport('fpp')
98
92
        self.assertEqualDiff(
120
114
            "read without data loss.",
121
115
            str(error))
122
116
 
123
 
    def test_jail_break(self):
124
 
        error = errors.JailBreak("some url")
125
 
        self.assertEqualDiff("An attempt to access a url outside the server"
126
 
            " jail was made: 'some url'.",
127
 
            str(error))
 
117
    def test_install_failed(self):
 
118
        error = errors.InstallFailed(['rev-one'])
 
119
        self.assertEqual("Could not install revisions:\nrev-one", str(error))
 
120
        error = errors.InstallFailed(['rev-one', 'rev-two'])
 
121
        self.assertEqual("Could not install revisions:\nrev-one, rev-two",
 
122
                         str(error))
 
123
        error = errors.InstallFailed([None])
 
124
        self.assertEqual("Could not install revisions:\nNone", str(error))
128
125
 
129
126
    def test_lock_active(self):
130
127
        error = errors.LockActive("lock description")
248
245
            "You will need to upgrade the branch to permit branch stacking.",
249
246
            str(error))
250
247
 
251
 
    def test_unstackable_location(self):
252
 
        error = errors.UnstackableLocationError('foo', 'bar')
253
 
        self.assertEqualDiff("The branch 'foo' cannot be stacked on 'bar'.",
254
 
            str(error))
255
 
 
256
248
    def test_unstackable_repository_format(self):
257
249
        format = u'foo'
258
250
        url = "/foo"
669
661
        e = ErrorWithBadFormat(not_thing='x')
670
662
        self.assertStartsWith(
671
663
            str(e), 'Unprintable exception ErrorWithBadFormat')
672
 
 
673
 
    def test_cannot_bind_address(self):
674
 
        # see <https://bugs.edge.launchpad.net/bzr/+bug/286871>
675
 
        e = errors.CannotBindAddress('example.com', 22,
676
 
            socket.error(13, 'Permission denied'))
677
 
        self.assertContainsRe(str(e),
678
 
            r'Cannot bind address "example\.com:22":.*Permission denied')