[Django] #24722: test client puts different results in response.context when nested view is redirected with process_request vs process_response middleware

14 views
Skip to first unread message

Django

unread,
Apr 28, 2015, 5:34:46 PM4/28/15
to django-...@googlegroups.com
#24722: test client puts different results in response.context when nested view is
redirected with process_request vs process_response middleware
-------------------------------+-------------------------
Reporter: electricjay | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Keywords: test client
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------
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

--
Ticket URL: <https://code.djangoproject.com/ticket/24722>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 28, 2015, 5:45:41 PM4/28/15
to django-...@googlegroups.com
#24722: test client puts different results in response.context when nested view is
redirected with process_request vs process_response middleware
-------------------------------+--------------------------------------

Reporter: electricjay | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Resolution:

Keywords: test client | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by electricjay):

* 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.

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>

Django

unread,
Apr 29, 2015, 12:39:16 PM4/29/15
to django-...@googlegroups.com
#24722: test client puts different results in response.context when nested view is
redirected with process_request vs process_response middleware
-----------------------------------+------------------------------------

Reporter: electricjay | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: test client | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by timgraham):

* component: Uncategorized => Testing framework
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/24722#comment:2>

Django

unread,
May 2, 2015, 2:50:51 AM5/2/15
to django-...@googlegroups.com
#24722: test client puts different results in response.context when nested view is
redirected with process_request vs process_response middleware
-----------------------------------+------------------------------------
Reporter: electricjay | Owner: nobody
Type: Bug | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: invalid

Keywords: test client | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by electricjay):

* 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>

Reply all
Reply to author
Forward
0 new messages