test.Response.status_code

status_code The HTTP status of the response, as an integer. For a full list of defined codes, see the IANA status code registry.

test.Response.resolver_match

resolver_match An instance of ResolverMatch for the response. You can use the func attribute, for example, to verify the view that served the response: # my_view here is a function based view self.assertEqual(response.resolver_match.func, my_view) # class-based views need to be compared by name, as the functions # generated by as_view() won't be equal self.assertEqual(response.resolver_match.func.__name__, MyView.as_view().__name__) If the given URL is not found, accessing this attribute w

test.Response.request

request The request data that stimulated the response.

test.Response.json()

json(**kwargs) New in Django 1.9. The body of the response, parsed as JSON. Extra keyword arguments are passed to json.loads(). For example: >>> response = client.get('/foo/') >>> response.json()['name'] 'Arthur' If the Content-Type header is not "application/json", then a ValueError will be raised when trying to parse the response.

test.Response.context

context The template Context instance that was used to render the template that produced the response content. If the rendered page used multiple templates, then context will be a list of Context objects, in the order in which they were rendered. Regardless of the number of templates used during rendering, you can retrieve context values using the [] operator. For example, the context variable name could be retrieved using: >>> response = client.get('/foo/') >>> response.co

test.Response.content

content The body of the response, as a bytestring. This is the final page content as rendered by the view, or any error message.

test.Response.client

client The test client that was used to make the request that resulted in the response.

test.Response

class Response client The test client that was used to make the request that resulted in the response. content The body of the response, as a bytestring. This is the final page content as rendered by the view, or any error message. context The template Context instance that was used to render the template that produced the response content. If the rendered page used multiple templates, then context will be a list of Context objects, in the order in which they were rendered. Re

test.RequestFactory

class RequestFactory [source] The RequestFactory shares the same API as the test client. However, instead of behaving like a browser, the RequestFactory provides a way to generate a request instance that can be used as the first argument to any view. This means you can test a view function the same way as you would test any other function – as a black box, with exactly known inputs, testing for specific outputs. The API for the RequestFactory is a slightly restricted subset of the test clien

test.override_settings()

override_settings() [source] In case you want to override a setting for a test method, Django provides the override_settings() decorator (see PEP 318). It’s used like this: from django.test import TestCase, override_settings class LoginTestCase(TestCase): @override_settings(LOGIN_URL='/other/login/') def test_login(self): response = self.client.get('/sekrit/') self.assertRedirects(response, '/other/login/?next=/sekrit/') The decorator can also be applied to TestCas