diff --git a/docs/api-guide/testing.md b/docs/api-guide/testing.md index b31d2c972..a6ecc7557 100644 --- a/docs/api-guide/testing.md +++ b/docs/api-guide/testing.md @@ -201,6 +201,8 @@ live environment. (See "Live tests" below.) This exposes exactly the same interface as if you were using a requests session directly. + from rest_framework.test import RequestsClient + client = RequestsClient() response = client.get('http://testserver/users/') assert response.status_code == 200 @@ -237,12 +239,12 @@ For example... client = RequestsClient() # Obtain a CSRF token. - response = client.get('/homepage/') + response = client.get('http://testserver/homepage/') assert response.status_code == 200 csrftoken = response.cookies['csrftoken'] # Interact with the API. - response = client.post('/organisations/', json={ + response = client.post('http://testserver/organisations/', json={ 'name': 'MegaCorp', 'status': 'active' }, headers={'X-CSRFToken': csrftoken})