31
31
class TestErrors(TestCaseWithTransport):
33
def test_disabled_method(self):
34
error = errors.DisabledMethod("class name")
36
"The smart server method 'class name' is disabled.", str(error))
38
def test_duplicate_file_id(self):
39
error = errors.DuplicateFileId('a_file_id', 'foo')
40
self.assertEqualDiff('File id {a_file_id} already exists in inventory'
41
' as foo', str(error))
43
def test_duplicate_help_prefix(self):
44
error = errors.DuplicateHelpPrefix('foo')
45
self.assertEqualDiff('The prefix foo is in the help search path twice.',
33
48
def test_inventory_modified(self):
34
49
error = errors.InventoryModified("a tree to be repred")
35
50
self.assertEqualDiff("The current inventory for the tree 'a tree to "
46
61
error = errors.InstallFailed([None])
47
62
self.assertEqual("Could not install revisions:\nNone", str(error))
64
def test_lock_active(self):
65
error = errors.LockActive("lock description")
66
self.assertEqualDiff("The lock for 'lock description' is in use and "
49
70
def test_knit_header_error(self):
50
71
error = errors.KnitHeaderError('line foo\n', 'path/to/file')
51
72
self.assertEqual("Knit header error: 'line foo\\n' unexpected"
52
73
" for file path/to/file", str(error))
75
def test_knit_index_unknown_method(self):
76
error = errors.KnitIndexUnknownMethod('http://host/foo.kndx',
78
self.assertEqual("Knit index http://host/foo.kndx does not have a"
79
" known method in options: ['bad', 'no-eol']",
54
82
def test_medium_not_connected(self):
55
83
error = errors.MediumNotConnected("a medium")
56
84
self.assertEqualDiff(
99
def test_no_help_topic(self):
100
error = errors.NoHelpTopic("topic")
101
self.assertEqualDiff("No help could be found for 'topic'. "
102
"Please use 'bzr help topics' to obtain a list of topics.",
71
105
def test_no_such_id(self):
72
106
error = errors.NoSuchId("atree", "anid")
73
107
self.assertEqualDiff("The file id anid is not present in the tree "
111
def test_no_such_revision_in_tree(self):
112
error = errors.NoSuchRevisionInTree("atree", "anid")
113
self.assertEqualDiff("The revision id anid is not present in the tree "
116
self.assertIsInstance(error, errors.NoSuchRevision)
77
118
def test_not_write_locked(self):
78
119
error = errors.NotWriteLocked('a thing to repr')
79
120
self.assertEqualDiff("'a thing to repr' is not write locked but needs "
124
def test_read_only_lock_error(self):
125
error = errors.ReadOnlyLockError('filename', 'error message')
126
self.assertEqualDiff("Cannot acquire write lock on filename."
127
" error message", str(error))
83
129
def test_too_many_concurrent_requests(self):
84
130
error = errors.TooManyConcurrentRequests("a medium")
85
131
self.assertEqualDiff("The medium 'a medium' has reached its concurrent "
86
132
"request limit. Be sure to finish_writing and finish_reading on "
87
"the current request that is open.",
133
"the currently open request.",
136
def test_unknown_hook(self):
137
error = errors.UnknownHook("branch", "foo")
138
self.assertEqualDiff("The branch hook 'foo' is unknown in this version"
141
error = errors.UnknownHook("tree", "bar")
142
self.assertEqualDiff("The tree hook 'bar' is unknown in this version"
90
146
def test_up_to_date(self):
188
244
host='ahost', port=444, msg='Unable to connect to ssh host',
189
245
orig_error='my_error')
247
def test_malformed_bug_identifier(self):
248
"""Test the formatting of MalformedBugIdentifier."""
249
error = errors.MalformedBugIdentifier('bogus', 'reason for bogosity')
251
"Did not understand bug identifier bogus: reason for bogosity",
254
def test_unknown_bug_tracker_abbreviation(self):
255
"""Test the formatting of UnknownBugTrackerAbbreviation."""
256
branch = self.make_branch('some_branch')
257
error = errors.UnknownBugTrackerAbbreviation('xxx', branch)
259
"Cannot find registered bug tracker called xxx on %s" % branch,
262
def test_unexpected_smart_server_response(self):
263
e = errors.UnexpectedSmartServerResponse(('not yes',))
265
"Could not understand response from smart server: ('not yes',)",
193
269
class PassThroughError(errors.BzrError):