test_decorators: Use the default value of user.

`HostRequestMock` has `user` default to `None`, which later gets
initialized as `AnonymousUser`. The separate initialization here is
unnecessary.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li 2022-07-18 17:14:42 -04:00 committed by Tim Abbott
parent a3efc777fa
commit 2925615ee7
1 changed files with 1 additions and 3 deletions

View File

@ -9,7 +9,6 @@ from unittest import mock, skipUnless
import orjson
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.utils.timezone import now as timezone_now
@ -1919,8 +1918,7 @@ class TestZulipLoginRequiredDecorator(ZulipTestCase):
return HttpResponse("Success")
with self.settings(TWO_FACTOR_AUTHENTICATION_ENABLED=True):
user = AnonymousUser()
request = HostRequestMock(user_profile=user)
request = HostRequestMock()
response = test_view(request)
self.assertEqual(response.content.decode(), "Success")