def test_provider_response_reraise(self): def blammo(): raise Exception('boom?') try: blammo() except Exception: r = base_sync.ProviderResponse(False, 404, {}, iter(['']), exc_info=sys.exc_info()) with self.assertRaises(Exception) as cm: r.reraise() self.assertEqual('boom?', cm.exception.message)
def test_provider_response_reraise_no_exc_info_long_body(self): headers = swob.HeaderEnvironProxy({ 'HTTP_FOO': 'bar', 'CONTENT_LENGTH': '88', }) r = base_sync.ProviderResponse(True, 204, headers, iter(['A'] * 100)) with self.assertRaises(ValueError) as cm: r.reraise() self.assertEqual( 'reraise had no prior exception for ' '<%s: %s, %r, %s, %r>' % ('ProviderResponse', 'True', 204, "{'Content-Length': '88', 'Foo': 'bar'}", ("A" * 70) + '...'), cm.exception.message)
def _head_object(*args, **kwargs): return base_sync.ProviderResponse( True, 204, {'Content-Length': parts[kwargs['PartNumber']]}, '')