{{{
def test_ok(self):
assert json.loads(self.client.get(url).content)['modified']
}}}
What would be nice is to have json on the test client, which can be parsed
if the response is application/json. We can mimic the requests interface
here:
http://docs.python-
requests.org/en/latest/api/?highlight=json#requests.Response.json
So it would look like this:
{{{
def test_ok(self):
assert self.client.get(url).json()['modified']
}}}
I wouldn't suggest we do this for every content type, but JSON is
everywhere. Like glitter.
--
Ticket URL: <https://code.djangoproject.com/ticket/24773>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => assigned
* needs_better_patch: => 0
* needs_tests: => 0
* version: 1.8 => master
* owner: nobody => andymckay
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/24773#comment:1>
* has_patch: 0 => 1
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/24773#comment:2>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/24773#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"4525a0c4669dccb3a4c5d865184f8bb8e4a89ec8" 4525a0c4]:
{{{
#!CommitTicketReference repository=""
revision="4525a0c4669dccb3a4c5d865184f8bb8e4a89ec8"
Fixed #24773 -- Added a json() method on test client responses.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24773#comment:4>