def test_user_info_with_non_django_auth(django_elasticapm_client, client):
with override_settings(INSTALLED_APPS=[
app for app in settings.INSTALLED_APPS
if app != 'django.contrib.auth'
]) and override_settings(MIDDLEWARE_CLASSES=[
m for m in settings.MIDDLEWARE_CLASSES
if m != 'django.contrib.auth.middleware.AuthenticationMiddleware'
]):
with pytest.raises(Exception):
resp = client.get(reverse('elasticapm-raise-exc'))
assert len(django_elasticapm_client.events) == 1
event = django_elasticapm_client.events.pop(0)['errors'][0]
assert event['context']['user'] == {}
评论列表
文章目录