When a view which calls another view and middleware causes the inner view
to redirect - the contents of '''results.context''' will be different
depending on if it was '''process_request''', or '''process_response'''
that initiated the redirect.
Test case for this error is in gitub:
https://github.com/electricjay/django/tree/test_client_nested_testcase
This problem was discovered when creating the pull request
https://github.com/django/django/pull/4574 for ticket #24696
--
Ticket URL: <https://code.djangoproject.com/ticket/24722>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> When using the test client:
>
> When a view which calls another view and middleware causes the inner view
> to redirect - the contents of '''results.context''' will be different
> depending on if it was '''process_request''', or '''process_response'''
> that initiated the redirect.
>
> Test case for this error is in gitub:
> https://github.com/electricjay/django/tree/test_client_nested_testcase
>
> This problem was discovered when creating the pull request
> https://github.com/django/django/pull/4574 for ticket #24696
New description:
When using the test client:
When a view calls another view and middleware causes the inner view to
redirect - the contents of '''response.context''' will be different
depending on if it was '''process_request''', or '''process_response'''
that initiated the redirect.
Test case for this error is in gitub:
https://github.com/electricjay/django/tree/test_client_nested_testcase
This problem was discovered when creating the pull request
https://github.com/django/django/pull/4574 for ticket #24696
--
--
Ticket URL: <https://code.djangoproject.com/ticket/24722#comment:1>
* component: Uncategorized => Testing framework
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/24722#comment:2>
* status: new => closed
* resolution: => invalid
Comment:
I have tracked the cause down and I no longer think this is a bug with the
test client.
When the redirect happens in **process_response** a 404 response is
created using a template before **process_response** is run. Thus the
test client is legitimately(?) adding the context from the 404 response to
the context of the response that is ultimately returned.
I suggest only modifying the test
test_client_regress.tests.ContextTests.test_nested_requests to not trigger
the ''common middleware''.
--
Ticket URL: <https://code.djangoproject.com/ticket/24722#comment:3>