Fixed the Middleware deprecation warnings by creating a dummy response function.
@@ -3,6 +3,7 @@ from django.contrib import messages
from django.contrib.auth.models import AnonymousUser
from django.contrib.messages.middleware import MessageMiddleware
from django.contrib.sessions.middleware import SessionMiddleware
+from django.http import HttpRequest
from django.http.response import Http404
from django.test import RequestFactory
@@ -27,6 +28,9 @@ class TestUserUpdateView:
https://github.com/pytest-dev/pytest-django/pull/258
"""
+ def dummy_get_response(self, request: HttpRequest):
+ return None
+
def test_get_success_url(self, user: User, rf: RequestFactory):
view = UserUpdateView()
request = rf.get("/fake-url/")
@@ -50,8 +54,8 @@ class TestUserUpdateView:
request = rf.get("/fake-url/")
# Add the session/message middleware to the request
- SessionMiddleware().process_request(request)
- MessageMiddleware().process_request(request)
+ SessionMiddleware(self.dummy_get_response).process_request(request)
+ MessageMiddleware(self.dummy_get_response).process_request(request)
request.user = user
view.request = request
