Opened 11 years ago
Closed 11 years ago
#21341 closed New feature (fixed)
Clean way of making https requests with test client
Reported by: | Unai Zalakain | Owned by: | Unai Zalakain |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | testing, client, https, secure |
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 is the current way of making an https request with the testing client:
from django.test import Client client = Client() client.get('/', {'wsgi.url_scheme': 'https'})
This is quite obscure and undocumented, something like client.get('/', secure=True)
would be far cleaner. The way
django.test.client.Client
and
django.test.client.RequestFactory
are build, we would need to modify each request method in both of them.
Change History (10)
comment:1 by , 11 years ago
Summary: | Add a secure kwarg to testing client request methods → Clean way for making https request with test client |
---|
comment:2 by , 11 years ago
Summary: | Clean way for making https request with test client → Clean way of making https request with test client |
---|
comment:3 by , 11 years ago
Summary: | Clean way of making https request with test client → Clean way of making https requests with test client |
---|
comment:4 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 by , 11 years ago
Has patch: | set |
---|
comment:7 by , 11 years ago
Status: | new → assigned |
---|
comment:8 by , 11 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
This looks pretty good to me. I left a few comments on the pull request. I'm marking as RFC anyway because these comments are minor and could be made by the committer.
comment:10 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
In: 99b681e227b5b7880d6edd0d8dd670034d431859
Fixed #21341 -- Eased https requests with the test client
PR sent: https://github.com/django/django/pull/1820
All the request methods of django.test.client.Client receive a secure
argument that defaults to False indicating wether or not to make the
request through https.