~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

  • Committer: Robert J. Tanner
  • Date: 2009-06-10 03:56:49 UTC
  • mfrom: (4423 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4425.
  • Revision ID: tanner@real-time.com-20090610035649-7rfx4cls4550zc3c
Merge 1.15.1 back to trunk

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"
542
531
            1/0
543
532
        except ZeroDivisionError:
544
533
            exc_info = sys.exc_info()
545
 
        err = errors.HookFailed('hook stage', 'hook name', exc_info, warn=False)
 
534
        err = errors.HookFailed('hook stage', 'hook name', exc_info)
546
535
        self.assertStartsWith(
547
536
            str(err), 'Hook \'hook name\' during hook stage failed:\n')
548
537
        self.assertEndsWith(
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')