django_tests.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:apm-agent-python 作者: elastic 项目源码 文件源码
def test_response_middlware_exception(django_elasticapm_client, client):
    if django.VERSION[:2] < (1, 3):
        return
    with override_settings(**middleware_setting(django.VERSION,
                                            ['tests.contrib.django.testapp.middleware.BrokenResponseMiddleware'])):
        with pytest.raises(ImportError):
            client.get(reverse('elasticapm-no-error'))

        assert len(django_elasticapm_client.events) == 1
        event = django_elasticapm_client.events.pop(0)['errors'][0]

        assert 'exception' in event
        exc = event['exception']
        assert exc['type'] == 'ImportError'
        assert exc['message'] == 'ImportError: response'
        assert event['culprit'] == 'tests.contrib.django.testapp.middleware.process_response'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号