test.SimpleTestCase.assertRedirects()

SimpleTestCase.assertRedirects(response, expected_url, status_code=302, target_status_code=200, msg_prefix='', fetch_redirect_response=True) [source] Asserts that the response returned a status_code redirect status, redirected to expected_url (including any GET data), and that the final page was received with target_status_code. If your request used the follow argument, the expected_url and target_status_code will be the url and status code for the final point of the redirect chain. If fetch

test.SimpleTestCase.assertTemplateUsed()

SimpleTestCase.assertTemplateUsed(response, template_name, msg_prefix='', count=None) [source] Asserts that the template with the given name was used in rendering the response. The name is a string such as 'admin/index.html'. The count argument is an integer indicating the number of times the template should be rendered. Default is None, meaning that the template should be rendered one or more times. You can use this as a context manager, like this: with self.assertTemplateUsed('index.html')

test.SimpleTestCase.assertTemplateNotUsed()

SimpleTestCase.assertTemplateNotUsed(response, template_name, msg_prefix='') [source] Asserts that the template with the given name was not used in rendering the response. You can use this as a context manager in the same way as assertTemplateUsed().

test.SimpleTestCase.assertXMLEqual()

SimpleTestCase.assertXMLEqual(xml1, xml2, msg=None) [source] Asserts that the strings xml1 and xml2 are equal. The comparison is based on XML semantics. Similarly to assertHTMLEqual(), the comparison is made on parsed content, hence only semantic differences are considered, not syntax differences. When invalid XML is passed in any parameter, an AssertionError is always raised, even if both string are identical. Output in case of error can be customized with the msg argument.

test.SimpleTestCase.assertHTMLNotEqual()

SimpleTestCase.assertHTMLNotEqual(html1, html2, msg=None) [source] Asserts that the strings html1 and html2 are not equal. The comparison is based on HTML semantics. See assertHTMLEqual() for details. html1 and html2 must be valid HTML. An AssertionError will be raised if one of them cannot be parsed. Output in case of error can be customized with the msg argument.

test.SimpleTestCase.assertJSONEqual()

SimpleTestCase.assertJSONEqual(raw, expected_data, msg=None) [source] Asserts that the JSON fragments raw and expected_data are equal. Usual JSON non-significant whitespace rules apply as the heavyweight is delegated to the json library. Output in case of error can be customized with the msg argument.

test.SimpleTestCase.assertNotContains()

SimpleTestCase.assertNotContains(response, text, status_code=200, msg_prefix='', html=False) [source] Asserts that a Response instance produced the given status_code and that text does not appear in the content of the response. Set html to True to handle text as HTML. The comparison with the response content will be based on HTML semantics instead of character-by-character equality. Whitespace is ignored in most cases, attribute ordering is not significant. See assertHTMLEqual() for more det

test.SimpleTestCase.assertInHTML()

SimpleTestCase.assertInHTML(needle, haystack, count=None, msg_prefix='') [source] Asserts that the HTML fragment needle is contained in the haystack one. If the count integer argument is specified, then additionally the number of needle occurrences will be strictly verified. Whitespace in most cases is ignored, and attribute ordering is not significant. The passed-in arguments must be valid HTML.

test.SimpleTestCase.assertJSONNotEqual()

SimpleTestCase.assertJSONNotEqual(raw, expected_data, msg=None) [source] Asserts that the JSON fragments raw and expected_data are not equal. See assertJSONEqual() for further details. Output in case of error can be customized with the msg argument.

test.SimpleTestCase.assertFieldOutput()

SimpleTestCase.assertFieldOutput(fieldclass, valid, invalid, field_args=None, field_kwargs=None, empty_value='') [source] Asserts that a form field behaves correctly with various inputs. Parameters: fieldclass – the class of the field to be tested. valid – a dictionary mapping valid inputs to their expected cleaned values. invalid – a dictionary mapping invalid inputs to one or more raised error messages. field_args – the args passed to instantiate the field. field_kwargs – the kwargs