[Django] #32470: django.test.Client ignores request.urlconf when setting response.resolver_match

35 views
Skip to first unread message

Django

unread,
Feb 21, 2021, 3:11:12 PM2/21/21
to django-...@googlegroups.com
#32470: django.test.Client ignores request.urlconf when setting
response.resolver_match
-------------------------------------+-------------------------------------
Reporter: Marc | Owner: Marc Gibbons
Gibbons |
Type: Bug | Status: assigned
Component: Testing | Version: master
framework | Keywords: test
Severity: Normal | client,urlconf,middleware,resolver_match,request,response
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
This bug is present in versions 2.2+.

When `request.urlconf` is set by middleware, and points to a module other
than the `ROOT_URLCONF`, the test client request will either:
a) Raise a `Resolver404` if the path resolved is not part of the
`ROOT_URLCONF` (even though the client has performed a successful
request); or
b) Resolve the path from `ROOT_URLCONF` module instead of the one set on
the `request.urlconf` attribute.

This occurs because the resolution of `response.resolver_match` only
considers the request path.

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

Django

unread,
Feb 22, 2021, 1:48:14 AM2/22/21
to django-...@googlegroups.com
#32470: django.test.Client ignores request.urlconf when setting
response.resolver_match
-------------------------------------+-------------------------------------
Reporter: Marc Gibbons | Owner: Marc

| Gibbons
Type: Bug | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: test | Triage Stage: Accepted
client,urlconf,middleware,resolver_match,request,response|
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

[https://github.com/django/django/pull/14028 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/32470#comment:1>

Django

unread,
Feb 23, 2021, 2:09:45 AM2/23/21
to django-...@googlegroups.com
#32470: django.test.Client ignores request.urlconf when setting
response.resolver_match
-------------------------------------+-------------------------------------
Reporter: Marc Gibbons | Owner: Marc

| Gibbons
Type: Bug | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: test | Triage Stage: Ready for
client,urlconf,middleware,resolver_match,request,response| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


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

Django

unread,
Feb 23, 2021, 4:46:03 AM2/23/21
to django-...@googlegroups.com
#32470: django.test.Client ignores request.urlconf when setting
response.resolver_match
-------------------------------------+-------------------------------------
Reporter: Marc Gibbons | Owner: Marc
| Gibbons
Type: Bug | Status: closed

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

Keywords: test | Triage Stage: Ready for
client,urlconf,middleware,resolver_match,request,response| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"d6572ee4b05b61d8c199b95a831f35a49c775f7e" d6572ee]:
{{{
#!CommitTicketReference repository=""
revision="d6572ee4b05b61d8c199b95a831f35a49c775f7e"
Fixed #32470 -- Fixed ResolverMatch instance on test clients when
request.urlconf is set.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32470#comment:3>

Reply all
Reply to author
Forward
0 new messages