~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

  • Committer: Joe Julian
  • Date: 2010-01-10 02:25:31 UTC
  • mto: (4634.119.7 2.0)
  • mto: This revision was merged to the branch mainline in revision 4959.
  • Revision ID: joe@julianfamily.org-20100110022531-wqk61rsagz8xsiga
Added MANIFEST.in to allow bdist_rpm to have all the required include files and tools. bdist_rpm will still fail to build correctly on some distributions due to a disttools bug http://bugs.python.org/issue644744

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
2
 
#   Authors: Robert Collins <robert.collins@canonical.com>
3
 
#            and others
 
1
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
4
2
#
5
3
# This program is free software; you can redistribute it and/or modify
6
4
# it under the terms of the GNU General Public License as published by
18
16
 
19
17
"""Tests for the formatting and construction of errors."""
20
18
 
 
19
import socket
21
20
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
 
90
96
    def test_in_process_transport(self):
91
97
        error = errors.InProcessTransport('fpp')
92
98
        self.assertEqualDiff(
114
120
            "read without data loss.",
115
121
            str(error))
116
122
 
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))
 
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))
125
128
 
126
129
    def test_lock_active(self):
127
130
        error = errors.LockActive("lock description")
245
248
            "You will need to upgrade the branch to permit branch stacking.",
246
249
            str(error))
247
250
 
 
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
 
248
256
    def test_unstackable_repository_format(self):
249
257
        format = u'foo'
250
258
        url = "/foo"
661
669
        e = ErrorWithBadFormat(not_thing='x')
662
670
        self.assertStartsWith(
663
671
            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')