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.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.assertRaisesMessage()

SimpleTestCase.assertRaisesMessage(expected_exception, expected_message, callable, *args, **kwargs) [source] SimpleTestCase.assertRaisesMessage(expected_exception, expected_message) Asserts that execution of callable raises expected_exception and that expected_message is found in the exception’s message. Any other outcome is reported as a failure. It’s a simpler version of unittest.TestCase.assertRaisesRegex() with the difference that expected_message isn’t treated as a regular expression.

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.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.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.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.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.assertHTMLEqual()

SimpleTestCase.assertHTMLEqual(html1, html2, msg=None) [source] Asserts that the strings html1 and html2 are equal. The comparison is based on HTML semantics. The comparison takes following things into account: Whitespace before and after HTML tags is ignored. All types of whitespace are considered equivalent. All open tags are closed implicitly, e.g. when a surrounding tag is closed or the HTML document ends. Empty tags are equivalent to their self-closing version. The ordering of attribute