55
55
args = inspect.getargspec(init)[0]
56
56
self.assertFalse('message' in args,
57
('Argument name "message" not allowed for '
58
'"errors.%s.__init__"' % c.__name__))
57
('Argument name "message" not allowed for '
58
'"errors.%s.__init__"' % c.__name__))
59
59
if fmt and fmt_pattern.search(fmt):
60
60
self.assertFalse(True, ('"message" not allowed in '
61
'"errors.%s._fmt"' % c.__name__))
61
'"errors.%s._fmt"' % c.__name__))
63
63
def test_bad_filename_encoding(self):
64
64
error = errors.BadFilenameEncoding(b'bad/filen\xe5me', 'UTF-8')
75
75
def test_duplicate_help_prefix(self):
76
76
error = errors.DuplicateHelpPrefix('foo')
77
77
self.assertEqualDiff('The prefix foo is in the help search path twice.',
80
80
def test_ghost_revisions_have_no_revno(self):
81
81
error = errors.GhostRevisionsHaveNoRevno('target', 'ghost_rev')
86
86
def test_incompatibleVersion(self):
87
87
error = errors.IncompatibleVersion("module", [(4, 5, 6), (7, 8, 9)],
89
89
self.assertEqualDiff(
90
90
'API module is not compatible; one of versions '
91
91
'[(4, 5, 6), (7, 8, 9)] is required, but current version is '
128
128
def test_inventory_modified(self):
129
129
error = errors.InventoryModified("a tree to be repred")
130
130
self.assertEqualDiff("The current inventory for the tree 'a tree to "
131
"be repred' has been modified, so a clean inventory cannot be "
132
"read without data loss.",
131
"be repred' has been modified, so a clean inventory cannot be "
132
"read without data loss.",
135
135
def test_jail_break(self):
136
136
error = errors.JailBreak("some url")
137
137
self.assertEqualDiff("An attempt to access a url outside the server"
138
" jail was made: 'some url'.",
138
" jail was made: 'some url'.",
141
141
def test_lock_active(self):
142
142
error = errors.LockActive("lock description")
143
143
self.assertEqualDiff("The lock for 'lock description' is in use and "
147
147
def test_lock_corrupt(self):
148
148
error = errors.LockCorrupt("corruption info")
149
149
self.assertEqualDiff("Lock is apparently held, but corrupted: "
151
"Use 'brz break-lock' to clear it",
151
"Use 'brz break-lock' to clear it",
154
154
def test_medium_not_connected(self):
155
155
error = errors.MediumNotConnected("a medium")
159
159
def test_no_smart_medium(self):
160
160
error = errors.NoSmartMedium("a transport")
161
161
self.assertEqualDiff("The transport 'a transport' cannot tunnel the "
165
165
def test_no_such_id(self):
166
166
error = errors.NoSuchId("atree", "anid")
167
167
self.assertEqualDiff("The file id \"anid\" is not present in the tree "
171
171
def test_no_such_revision_in_tree(self):
172
172
error = errors.NoSuchRevisionInTree("atree", "anid")
177
177
def test_not_stacked(self):
178
178
error = errors.NotStacked('a branch')
179
179
self.assertEqualDiff("The branch 'a branch' is not stacked.",
182
182
def test_not_write_locked(self):
183
183
error = errors.NotWriteLocked('a thing to repr')
184
184
self.assertEqualDiff("'a thing to repr' is not write locked but needs "
188
188
def test_lock_failed(self):
189
error = errors.LockFailed('http://canonical.com/', 'readonly transport')
189
error = errors.LockFailed(
190
'http://canonical.com/', 'readonly transport')
190
191
self.assertEqualDiff("Cannot lock http://canonical.com/: readonly transport",
192
193
self.assertFalse(error.internal_error)
194
195
def test_too_many_concurrent_requests(self):
195
196
error = errors.TooManyConcurrentRequests("a medium")
196
197
self.assertEqualDiff("The medium 'a medium' has reached its concurrent "
197
"request limit. Be sure to finish_writing and finish_reading on "
198
"the currently open request.",
198
"request limit. Be sure to finish_writing and finish_reading on "
199
"the currently open request.",
201
202
def test_unavailable_representation(self):
202
error = errors.UnavailableRepresentation(('key',), "mpdiff", "fulltext")
203
error = errors.UnavailableRepresentation(
204
('key',), "mpdiff", "fulltext")
203
205
self.assertEqualDiff("The encoding 'mpdiff' is not available for key "
204
"('key',) which is encoded as 'fulltext'.",
206
"('key',) which is encoded as 'fulltext'.",
207
209
def test_unstackable_location(self):
208
210
error = errors.UnstackableLocationError('foo', 'bar')
209
211
self.assertEqualDiff("The branch 'foo' cannot be stacked on 'bar'.",
212
214
def test_unstackable_repository_format(self):
243
245
def test_reading_completed(self):
244
246
error = errors.ReadingCompleted("a request")
245
247
self.assertEqualDiff("The MediumRequest 'a request' has already had "
246
"finish_reading called upon it - the request has been completed and"
247
" no more data may be read.",
248
"finish_reading called upon it - the request has been completed and"
249
" no more data may be read.",
250
252
def test_writing_completed(self):
251
253
error = errors.WritingCompleted("a request")
252
254
self.assertEqualDiff("The MediumRequest 'a request' has already had "
253
"finish_writing called upon it - accept bytes may not be called "
255
"finish_writing called upon it - accept bytes may not be called "
257
259
def test_writing_not_completed(self):
258
260
error = errors.WritingNotComplete("a request")
259
261
self.assertEqualDiff("The MediumRequest 'a request' has not has "
260
"finish_writing called upon it - until the write phase is complete"
261
" no data may be read.",
262
"finish_writing called upon it - until the write phase is complete"
263
" no data may be read.",
264
266
def test_transport_not_possible(self):
265
267
error = errors.TransportNotPossible('readonly', 'original error')
266
268
self.assertEqualDiff('Transport operation not possible:'
267
' readonly original error', str(error))
269
' readonly original error', str(error))
269
271
def assertSocketConnectionError(self, expected, *args, **kwargs):
270
272
"""Check the formatting of a SocketConnectionError exception"""
467
469
def test_recursive_bind(self):
468
470
error = errors.RecursiveBind('foo_bar_branch')
469
471
msg = ('Branch "foo_bar_branch" appears to be bound to itself. '
470
'Please use `brz unbind` to fix.')
472
'Please use `brz unbind` to fix.')
471
473
self.assertEqualDiff(msg, str(error))
473
475
def test_retry_with_new_packs(self):
552
554
def test_no_repo(self):
553
555
dir = controldir.ControlDir.create(self.get_url())
554
556
error = errors.NoRepositoryPresent(dir)
555
self.assertNotEqual(-1, str(error).find((dir.transport.clone('..').base)))
557
self.assertNotEqual(-1,
558
str(error).find((dir.transport.clone('..').base)))
556
559
self.assertEqual(-1, str(error).find((dir.transport.base)))
558
561
def test_corrupt_repository(self):
577
580
def test_not_branch_laziness(self):
578
581
real_bzrdir = self.make_controldir('path')
579
583
class FakeBzrDir(object):
580
584
def __init__(self):
582
587
def open_repository(self):
583
588
self.calls.append('open_repository')
584
589
raise errors.NoRepositoryPresent(real_bzrdir)