| 1 | diff --git a/django/test/client.py b/django/test/client.py
|
|---|
| 2 | index 6ea8119..7eb56a6 100644
|
|---|
| 3 | --- a/django/test/client.py
|
|---|
| 4 | +++ b/django/test/client.py
|
|---|
| 5 | @@ -8,7 +8,7 @@ from copy import copy
|
|---|
| 6 | from io import BytesIO
|
|---|
| 7 |
|
|---|
| 8 | from django.conf import settings
|
|---|
| 9 | -from django.contrib.auth import authenticate, login, logout, get_user_model
|
|---|
| 10 | +from django.contrib.auth import authenticate, login, logout, get_user
|
|---|
| 11 | from django.core.handlers.base import BaseHandler
|
|---|
| 12 | from django.core.handlers.wsgi import WSGIRequest
|
|---|
| 13 | from django.core.signals import (request_started, request_finished,
|
|---|
| 14 | @@ -586,12 +586,11 @@ class Client(RequestFactory):
|
|---|
| 15 | """
|
|---|
| 16 | request = HttpRequest()
|
|---|
| 17 | engine = import_module(settings.SESSION_ENGINE)
|
|---|
| 18 | - UserModel = get_user_model()
|
|---|
| 19 | if self.session:
|
|---|
| 20 | request.session = self.session
|
|---|
| 21 | uid = self.session.get("_auth_user_id")
|
|---|
| 22 | if uid:
|
|---|
| 23 | - request.user = UserModel._default_manager.get(pk=uid)
|
|---|
| 24 | + request.user = get_user(request)
|
|---|
| 25 | else:
|
|---|
| 26 | request.session = engine.SessionStore()
|
|---|
| 27 | logout(request)
|
|---|