{{{
self.client.get("/", HTTP_ACCEPT_LANGUAGE="en")
}}}
I propose we add support for a `headers` argument that takes a dictionary
like `request.headers`:
{{{
self.client.get("/", headers={"accept-language": "en"})
}}}
This would make tests easier to read and write, since they’d be consistent
with `HttpRequest`.
(If this is accepted and merged, open a [https://github.com/adamchainz
/django-upgrade/ django-upgrade] issue to rewrite request factory and
client invocations.)
--
Ticket URL: <https://code.djangoproject.com/ticket/34074>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
Comment:
Sounds good.
--
Ticket URL: <https://code.djangoproject.com/ticket/34074#comment:1>
* cc: David Wobrock (added)
* owner: nobody => David Wobrock
* has_patch: 0 => 1
* status: new => assigned
Comment:
I agree that it would come in handy!
Here's a [https://github.com/django/django/pull/16163 draft PR].
--
Ticket URL: <https://code.djangoproject.com/ticket/34074#comment:2>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34074#comment:3>
* needs_better_patch: 1 => 0
* needs_docs: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34074#comment:4>
* needs_docs: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/34074#comment:5>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34074#comment:6>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/34074#comment:7>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/34074#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"67da22f08e05018ea968fcacbac9ac37ea925d85" 67da22f]:
{{{
#!CommitTicketReference repository=""
revision="67da22f08e05018ea968fcacbac9ac37ea925d85"
Fixed #34074 -- Added headers argument to RequestFactory and Client
classes.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34074#comment:9>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"99bd5fb4c2d51f7bf8a19b2c12a603ab38b85ec9" 99bd5fb4]:
{{{
#!CommitTicketReference repository=""
revision="99bd5fb4c2d51f7bf8a19b2c12a603ab38b85ec9"
Refs #34074 -- Used headers argument for RequestFactory and Client in docs
and tests.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34074#comment:10>