def test_broken_500_handler_with_middleware(django_elasticapm_client, client):
with override_settings(BREAK_THAT_500=True):
client.handler = MockMiddleware(MockClientHandler())
with override_settings(**middleware_setting(django.VERSION, [])):
with pytest.raises(Exception):
client.get(reverse('elasticapm-raise-exc'))
assert len(django_elasticapm_client.events) == 2
event = django_elasticapm_client.events.pop(0)['errors'][0]
assert 'exception' in event
exc = event['exception']
assert exc['type'] == 'Exception'
assert exc['message'] == 'Exception: view exception'
assert event['culprit'] == 'tests.contrib.django.testapp.views.raise_exc'
event = django_elasticapm_client.events.pop(0)['errors'][0]
assert 'exception' in event
exc = event['exception']
assert exc['type'] == 'ValueError'
assert exc['message'] == 'ValueError: handler500'
assert event['culprit'] == 'tests.contrib.django.testapp.urls.handler500'
评论列表
文章目录