#21476 closed Cleanup/optimization (fixed)
Cache tests make an incorrect use of `HttpRequest`
Reported by: | Unai Zalakain | Owned by: | Unai Zalakain |
---|---|---|---|
Component: | Core (Cache system) | Version: | dev |
Severity: | Normal | Keywords: | tests, cache, request |
Cc: | Baptiste Mispelon | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Cache tests directly append the query string to the request path:
request = HttpRequest() request.META = { 'SERVER_NAME': 'testserver', 'SERVER_PORT': 80, } request.method = method request.path = request.path_info = "/cache/%s" % path return request
HttpRequest.get_full_path()
uses the HttpRequest.META['QUERY_STRING']
attribute to determine, escape and encode the query string.
Change History (6)
comment:1 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 11 years ago
Has patch: | set |
---|
comment:3 by , 11 years ago
Cc: | added |
---|---|
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
Yes, it seems that the tests have accumulated some cruft over the years and they could use some cleaning up.
I'm accepting the ticket on this basis.
In particular (though the list is probably not exhaustive):
- Use
django.test.RequestFactory
instead of manually constructingHttpRequest
objects - Get rid of the various inconsistent
_get_request
method on the test cases (they have different signatures, some prependself.path
and others don't, ...)
comment:4 by , 11 years ago
Patch needs improvement: | unset |
---|
PR updated, all the _get_request
mess has been substituted by django.test.client.RequestFactory
;)
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
PR sent: https://github.com/django/django/pull/1950