I'm having problems using the Django Client () test to test middleware. It seems like emulating middleware sessions. However, since it is based on RequestFactory, it does not seem to run any middleware.
Is there a way to get the test client to use middleware for both request and response? I understand that often there are other ways to specifically test middleware. However, in some cases, I would like to test the request with a full stack of middleware. Any way to do this?
I thought about expanding the Client and changing its request () class and executing the request through the middleware stack at the beginning of the function, as well as the answer through the middleware stack at the bottom of the function. Do you think such a thing will work? If not, can you point me to some resources that could explain why?
python django django-middleware django-testing
Krystian cybulski
source share