Clean way of making https requests with test client
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)
| Summary: |
Add a secure kwarg to testing client request methods → Clean way for making https request with test client
|
| Summary: |
Clean way for making https request with test client → Clean way of making https request with test client
|
| Summary: |
Clean way of making https request with test client → Clean way of making https requests with test client
|
| Triage Stage: |
Unreviewed → Accepted
|
| Triage Stage: |
Accepted → Ready for checkin
|
| Resolution: |
→ fixed
|
| Status: |
assigned → closed
|
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.