~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

  • Committer: Johan Walles
  • Date: 2009-05-06 05:36:28 UTC
  • mfrom: (4332 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4343.
  • Revision ID: johan.walles@gmail.com-20090506053628-tbf1wz4a0m9t684g
MergeĀ fromĀ upstream.

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(
248
242
            "You will need to upgrade the branch to permit branch stacking.",
249
243
            str(error))
250
244
 
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
245
    def test_unstackable_repository_format(self):
257
246
        format = u'foo'
258
247
        url = "/foo"
669
658
        e = ErrorWithBadFormat(not_thing='x')
670
659
        self.assertStartsWith(
671
660
            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')