Opened 4 years ago

Closed 4 years ago

#32470 closed Bug (fixed)

django.test.Client ignores request.urlconf when setting response.resolver_match

Reported by: Marc Gibbons Owned by: Marc Gibbons
Component: Testing framework Version: dev
Severity: Normal Keywords: test client, urlconf, middleware, resolver_match, request, response
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (3)

comment:1 by Mariusz Felisiak, 4 years ago

Has patch: set
Triage Stage: UnreviewedAccepted

comment:2 by Mariusz Felisiak, 4 years ago

Triage Stage: AcceptedReady for checkin

comment:3 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In d6572ee:

Fixed #32470 -- Fixed ResolverMatch instance on test clients when request.urlconf is set.

Note: See TracTickets for help on using tickets.
Back to Top