/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_smart_request.py

Merge test-run support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
 
51
51
class ChunkErrorRequest(request.SmartServerRequest):
52
52
    """A request that raises an error from self.do_chunk()."""
53
 
 
 
53
    
54
54
    def do(self):
55
55
        """No-op."""
56
56
        pass
61
61
 
62
62
class EndErrorRequest(request.SmartServerRequest):
63
63
    """A request that raises an error from self.do_end()."""
64
 
 
 
64
    
65
65
    def do(self):
66
66
        """No-op."""
67
67
        pass
69
69
    def do_chunk(self, bytes):
70
70
        """No-op."""
71
71
        pass
72
 
 
 
72
        
73
73
    def do_end(self):
74
74
        raise errors.NoSuchFile('xyzzy')
75
75
 
135
135
                unclassified_requests.append(key)
136
136
        if unclassified_requests:
137
137
            self.fail('These requests were not categorized as safe/unsafe'
138
 
                      ' to retry: %s' % (unclassified_requests,))
 
138
                      ' to retry: %s'  % (unclassified_requests,))
139
139
 
140
140
 
141
141
class TestSmartRequestHandlerErrorTranslation(TestCase):
215
215
 
216
216
    def test_generic_Exception(self):
217
217
        self.assertTranslationEqual((b'error', b'Exception', b""),
218
 
                                    Exception())
 
218
            Exception())
219
219
 
220
220
    def test_generic_BzrError(self):
221
221
        self.assertTranslationEqual((b'error', b'BzrError', b"some text"),
222
 
                                    errors.BzrError(msg="some text"))
 
222
            errors.BzrError(msg="some text"))
223
223
 
224
224
    def test_generic_zlib_error(self):
225
225
        from zlib import error
226
226
        msg = "Error -3 while decompressing data: incorrect data check"
227
227
        self.assertTranslationEqual((b'error', b'zlib.error', msg.encode('utf-8')),
228
 
                                    error(msg))
 
228
            error(msg))
229
229
 
230
230
 
231
231
class TestRequestJail(TestCaseWithMemoryTransport):
244
244
 
245
245
    def setUp(self):
246
246
        super(TestJailHook, self).setUp()
247
 
 
248
247
        def clear_jail_info():
249
248
            request.jail_info.transports = None
250
249
        self.addCleanup(clear_jail_info)
268
267
 
269
268
    def test_open_bzrdir_in_non_main_thread(self):
270
269
        """Opening a bzrdir in a non-main thread should work ok.
271
 
 
 
270
        
272
271
        This makes sure that the globally-installed
273
272
        breezy.bzr.smart.request._pre_open_hook, which uses a threading.local(),
274
273
        works in a newly created thread.
276
275
        bzrdir = self.make_controldir('.')
277
276
        transport = bzrdir.root_transport
278
277
        thread_result = []
279
 
 
280
278
        def t():
281
279
            BzrDir.open_from_transport(transport)
282
280
            thread_result.append('ok')
284
282
        thread.start()
285
283
        thread.join()
286
284
        self.assertEqual(['ok'], thread_result)
 
285