/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_errors.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-02 02:35:46 UTC
  • mfrom: (7309 work)
  • mto: This revision was merged to the branch mainline in revision 7319.
  • Revision ID: jelmer@jelmer.uk-20190602023546-lqco868tnv26d8ow
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
                else:
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__))
62
62
 
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.',
78
 
            str(error))
 
78
                             str(error))
79
79
 
80
80
    def test_ghost_revisions_have_no_revno(self):
81
81
        error = errors.GhostRevisionsHaveNoRevno('target', 'ghost_rev')
85
85
 
86
86
    def test_incompatibleVersion(self):
87
87
        error = errors.IncompatibleVersion("module", [(4, 5, 6), (7, 8, 9)],
88
 
                (1, 2, 3))
 
88
                                           (1, 2, 3))
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.",
133
 
            str(error))
 
131
                             "be repred' has been modified, so a clean inventory cannot be "
 
132
                             "read without data loss.",
 
133
                             str(error))
134
134
 
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'.",
139
 
            str(error))
 
138
                             " jail was made: 'some url'.",
 
139
                             str(error))
140
140
 
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 "
144
 
            "cannot be broken.",
145
 
            str(error))
 
144
                             "cannot be broken.",
 
145
                             str(error))
146
146
 
147
147
    def test_lock_corrupt(self):
148
148
        error = errors.LockCorrupt("corruption info")
149
149
        self.assertEqualDiff("Lock is apparently held, but corrupted: "
150
 
            "corruption info\n"
151
 
            "Use 'brz break-lock' to clear it",
152
 
            str(error))
 
150
                             "corruption info\n"
 
151
                             "Use 'brz break-lock' to clear it",
 
152
                             str(error))
153
153
 
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 "
162
 
            "smart protocol.",
163
 
            str(error))
 
162
                             "smart protocol.",
 
163
                             str(error))
164
164
 
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 "
168
 
            "atree.",
169
 
            str(error))
 
168
                             "atree.",
 
169
                             str(error))
170
170
 
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.",
180
 
            str(error))
 
180
                             str(error))
181
181
 
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 "
185
 
            "to be.",
186
 
            str(error))
 
185
                             "to be.",
 
186
                             str(error))
187
187
 
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",
191
 
            str(error))
 
192
                             str(error))
192
193
        self.assertFalse(error.internal_error)
193
194
 
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.",
199
 
            str(error))
 
198
                             "request limit. Be sure to finish_writing and finish_reading on "
 
199
                             "the currently open request.",
 
200
                             str(error))
200
201
 
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'.",
205
 
            str(error))
 
206
                             "('key',) which is encoded as 'fulltext'.",
 
207
                             str(error))
206
208
 
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'.",
210
 
            str(error))
 
212
                             str(error))
211
213
 
212
214
    def test_unstackable_repository_format(self):
213
215
        format = u'foo'
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
 
            str(error))
 
248
                             "finish_reading called upon it - the request has been completed and"
 
249
                             " no more data may be read.",
 
250
                             str(error))
249
251
 
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 "
254
 
            "anymore.",
255
 
            str(error))
 
255
                             "finish_writing called upon it - accept bytes may not be called "
 
256
                             "anymore.",
 
257
                             str(error))
256
258
 
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
 
            str(error))
 
262
                             "finish_writing called upon it - until the write phase is complete"
 
263
                             " no data may be read.",
 
264
                             str(error))
263
265
 
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))
268
270
 
269
271
    def assertSocketConnectionError(self, expected, *args, **kwargs):
270
272
        """Check the formatting of a SocketConnectionError exception"""
481
483
    def test_recursive_bind(self):
482
484
        error = errors.RecursiveBind('foo_bar_branch')
483
485
        msg = ('Branch "foo_bar_branch" appears to be bound to itself. '
484
 
            'Please use `brz unbind` to fix.')
 
486
               'Please use `brz unbind` to fix.')
485
487
        self.assertEqualDiff(msg, str(error))
486
488
 
487
489
    def test_retry_with_new_packs(self):
566
568
    def test_no_repo(self):
567
569
        dir = controldir.ControlDir.create(self.get_url())
568
570
        error = errors.NoRepositoryPresent(dir)
569
 
        self.assertNotEqual(-1, str(error).find((dir.transport.clone('..').base)))
 
571
        self.assertNotEqual(-1,
 
572
                            str(error).find((dir.transport.clone('..').base)))
570
573
        self.assertEqual(-1, str(error).find((dir.transport.base)))
571
574
 
572
575
    def test_corrupt_repository(self):
590
593
 
591
594
    def test_not_branch_laziness(self):
592
595
        real_bzrdir = self.make_controldir('path')
 
596
 
593
597
        class FakeBzrDir(object):
594
598
            def __init__(self):
595
599
                self.calls = []
 
600
 
596
601
            def open_repository(self):
597
602
                self.calls.append('open_repository')
598
603
                raise errors.NoRepositoryPresent(real_bzrdir)