Skip to content

Commit 8c03c49

Browse files
cgltomchristie
authored andcommitted
update testing.md - fixes related to RequestsClient (#5959)
* Include import for RequestsClient in the docs. * Use fully qualified URLs for `RequestsClient` in the docs.
1 parent a11938c commit 8c03c49

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/api-guide/testing.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ live environment. (See "Live tests" below.)
201201
This exposes exactly the same interface as if you were using a requests session
202202
directly.
203203

204+
from rest_framework.test import RequestsClient
205+
204206
client = RequestsClient()
205207
response = client.get('http://testserver/users/')
206208
assert response.status_code == 200
@@ -237,12 +239,12 @@ For example...
237239
client = RequestsClient()
238240

239241
# Obtain a CSRF token.
240-
response = client.get('/homepage/')
242+
response = client.get('http://testserver/homepage/')
241243
assert response.status_code == 200
242244
csrftoken = response.cookies['csrftoken']
243245

244246
# Interact with the API.
245-
response = client.post('/organisations/', json={
247+
response = client.post('http://testserver/organisations/', json={
246248
'name': 'MegaCorp',
247249
'status': 'active'
248250
}, headers={'X-CSRFToken': csrftoken})

0 commit comments

Comments
 (0)